BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Questions about using Blob fields

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Enquiring Mind
Guest





PostPosted: Fri Apr 13, 2007 3:28 pm    Post subject: Questions about using Blob fields Reply with quote



Hi,

Can anyone help with the following questions about using a Blob field that
stores unformatted text (memo), where the database server is Interbase?

1. Blob storage. I have seen it mentioned in a book that blobs are stored in
segments of a fixed size. Does this mean that an allocated segment is filled
with as many blob field values as it can accommodate, so that if say, a blob
field contains a string of only 20 characters, the space it will occupy in
the segment will be 20 characters, plus a length parameter, and the field in
the record will contain a reference to the segment and the location within
the segment where the string resides? If segments can contain multiple blob
values, is there a way of compacting (defragmenting) the bob storage after a
number of deletions have been made, thereby creating unused gaps?

2. Searching Blobs on the database. With reference to a table Records that
contains a blob field called Comments, the SQL statement
select * from Records where Comments like '%Delphi%'
is case-sensitive. What is the most efficient way of doing a
case-insensitive search for a blob field that contains a specified string?

3. I have created a persistent field object for the field Comments and set
the Blob Type property to ftMemo. The CDS cdsRecords is linked to a TDBGrid
control. How can I get the 'Comments' column cells to display say the first
two lines of the memo instead of the string '(Blob)'?

4. If the Blob is linked to a DBMemo control in a single record view, does
the DBMemo insert line separation character strings corresponding to the
lines in the memo control, or is the text saved to the blob with no line
separators, and the line structure determined on the fly when the memo data
is read from the blob field?

5. Following on from question 3, if I use a TDBCtrlGrid instead of a TDBGrid
so that I can embed a TDBMemo in a cell to display a blob, how can I display
column headings?

Thanks in advance for any help.

Enquiring Mind
Back to top
Bill Todd
Guest





PostPosted: Fri Apr 13, 2007 9:07 pm    Post subject: Re: Questions about using Blob fields Reply with quote



Enquiring Mind wrote:

Quote:
Hi,

Can anyone help with the following questions about using a Blob field
that stores unformatted text (memo), where the database server is
Interbase?

1. Blob storage. I have seen it mentioned in a book that blobs are
stored in segments of a fixed size. Does this mean that an allocated
segment is filled with as many blob field values as it can
accommodate, so that if say, a blob field contains a string of only
20 characters, the space it will occupy in the segment will be 20
characters, plus a length parameter, and the field in the record will
contain a reference to the segment and the location within the
segment where the string resides? If segments can contain multiple
blob values, is there a way of compacting (defragmenting) the bob
storage after a number of deletions have been made, thereby creating
unused gaps?

My understanding is that one segment can contain data from one blob.
I'll leave it to someone who knows more about IB internals to confirm
or correct this.

Quote:

2. Searching Blobs on the database. With reference to a table Records
that contains a blob field called Comments, the SQL statement select
* from Records where Comments like '%Delphi%' is case-sensitive. What
is the most efficient way of doing a case-insensitive search for a
blob field that contains a specified string?

WHERE ABLOB CONTAINING 'ABC'

Quote:

3. I have created a persistent field object for the field Comments
and set the Blob Type property to ftMemo. The CDS cdsRecords is
linked to a TDBGrid control. How can I get the 'Comments' column
cells to display say the first two lines of the memo instead of the
string '(Blob)'?

Write an OnGetText event handler for the field object.

Quote:

4. If the Blob is linked to a DBMemo control in a single record view,
does the DBMemo insert line separation character strings
corresponding to the lines in the memo control, or is the text saved
to the blob with no line separators, and the line structure
determined on the fly when the memo data is read from the blob field?

What you type into the DBMemo is what is stored. If you press the Enter
key while typing in the DBMemo a carriage return/line feed sequence is
inserted into the DBMemo and will be stored in the database.

Quote:

5. Following on from question 3, if I use a TDBCtrlGrid instead of a
TDBGrid so that I can embed a TDBMemo in a cell to display a blob,
how can I display column headings?

Use a TLabel.


--
Bill Todd (TeamB)
Back to top
Enquiring Mind
Guest





PostPosted: Mon Apr 16, 2007 2:40 pm    Post subject: Re: Questions about using Blob fields Reply with quote



"Bill Todd" <no (AT) no (DOT) com> wrote in message
news:461f9cb3$1 (AT) newsgroups (DOT) borland.com...
Quote:
Enquiring Mind wrote:

Thanks for your help.


Quote:
My understanding is that one segment can contain data from one blob.
I'll leave it to someone who knows more about IB internals to confirm
or correct this.

Just to recast the query in simpler terms, what is the minimum amount of

storage space that a Blob field occupies in the database file?

Quote:
3. I have created a persistent field object for the field Comments
and set the Blob Type property to ftMemo. The CDS cdsRecords is
linked to a TDBGrid control. How can I get the 'Comments' column
cells to display say the first two lines of the memo instead of the
string '(Blob)'?

Write an OnGetText event handler for the field object.

The snag with this approach is that the event handler belongs to the field

object rather than the visual control, so that the string manipulation
executed within the handler would be common to any visual control pointing
to the field object. Thus, contrary to what is required, any visual control
pointing to the field object would display a curtailed memo. Therefore I
looked into following a similar approach using the TColumn property of the
TDBGrid control, but found that it does not expose an OnGetText event. I
suppose that one could fall back on doing the string manipulation in an
OnDrawColumnCell event handler for the data-ware grid, though this is a
little tedious because it's done at the level of canvas graphics.

Enquiring Mind
Back to top
Bill Todd
Guest





PostPosted: Mon Apr 16, 2007 7:55 pm    Post subject: Re: Questions about using Blob fields Reply with quote

Enquiring Mind wrote:

Quote:
Just to recast the query in simpler terms, what is the minimum amount
of storage space that a Blob field occupies in the database file?

I have no idea. My guess is one segment so the size depends on what you
set the segment size to.

If you just want to affect the grid then OnDrawColumnCell is the
solution.

--
Bill Todd (TeamB)
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Tue Apr 17, 2007 12:20 am    Post subject: Re: Questions about using Blob fields Reply with quote

Enquiring Mind wrote:

Quote:
Just to recast the query in simpler terms, what is the minimum amount
of storage space that a Blob field occupies in the database file?

In IB a blob is a pointer. If it's set to NULL then you just have room
for the page and the offset; not huge. When it actuall points to
something you need the contents itself plus some header info to
indicate the transaction number and the like.

--
Craig Stuntz [TeamB] ˇ Vertex Systems Corp. ˇ Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Borland newsgroup denizen Sergio González has a new CD of
Irish music out, and it's good: http://tinyurl.com/7hgfr
Back to top
Kees Vermeulen (Kever-IT)
Guest





PostPosted: Tue Apr 17, 2007 4:40 pm    Post subject: Re: Questions about using Blob fields Reply with quote

Hello,

Quote:

1. Blob storage. I have seen it mentioned in a book that blobs are stored in
segments of a fixed size. Does this mean that an allocated segment is filled
with as many blob field values as it can accommodate, so that if say, a blob
field contains a string of only 20 characters, the space it will occupy in
the segment will be 20 characters, plus a length parameter, and the field in
the record will contain a reference to the segment and the location within
the segment where the string resides? If segments can contain multiple blob
values, is there a way of compacting (defragmenting) the bob storage after a
number of deletions have been made, thereby creating unused gaps?


Blobs are stored in a separate location and are segmented in blocks of
the same size. If the blob is smaller than blocksize, a complete block
is still allocated. If a blob is larger than blocksize, a second block
is added. I'm not sure if and how you can control the size of the blocks.

This storage mechanism looks like the way files are stored on a disk.

Quote:
3. I have created a persistent field object for the field Comments and set
the Blob Type property to ftMemo. The CDS cdsRecords is linked to a TDBGrid
control. How can I get the 'Comments' column cells to display say the first
two lines of the memo instead of the string '(Blob)'?

Add a calculated string field to your dataset which is set to the first
two lines of your memo using event OnCalcFields. This way you can
display the summary AND the full memo using appropriete controls.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.