problem with Blobs

Hello.
I have a problem with Blobs (D5, Interbase). I have a table like this:
create table test(
    id                integer primary key,
    content       varchar(512));
All works fine when TQuery likes "select id from test", but when i try to run
"select id, content from test" statement i get "RecordCount = -1" and
message "The logical BLOB handle in the record buffer is invalid."
I added the parameter "Blobs To Cache=-1", but  it doesn't fix the problem.

Does
anyone have any ideas?
VitttAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
hi vittt,

from borland (a bit older), but maybe actuell enough for your problem

---- paste begin

Question and Answer Database

      FAQ387B.txt   'Invalid BLOb handle' error
      Category   :Database (Miscellaneous)
      Platform    :All
      Product    :BDE 4.0  

      Question:
      "Invalid BLOb handle" error: What is the cause and
      how do I fix this error?

      Answer:

      If the error occurs on a non-live (dead, canned) query or a
      table with no indexes, then increasing the new BDE 4.x
      configuration parameter 'BLOBS TO CACHE' will fix the problem.
      This setting determines how many BLObs will be cached on the
      client. Applications that deal with fetching dead BLObs using
      dead table opens or queries can set a limit on the number of
      BLObs to cache depending on the resource available on the
      client. Setting a value 100 means the application can work with
      a maximum of 100 BLOb records cached. Fetching more than 100,
      then scrolling back 100 records results in an "Invalid BLOb
      handle in record buffer" error message.

      NOTE:This parameter does not apply to live table opens.

      Default Value: 64
      Range: 64 to 65536

      7/15/98 3:23:06 PM

---- paste end

therefore raise the cache to blob entry or force that your resultset is live - by a query set the requestlive-property to true

meikl
0
karooCommented:
Vitt,

i agree with meikl on setting the cache size.

just want to point out another issue which may help you.

by using:
create table test(
  id        integer primary key,
  content   varchar(512)
);

Interbase stores the variable length data on disk as fixed length by adding spaces until the size defined is reached. So if you add a record with 100 chars in content then Interbase will pad the rest of the column with spaces until 512 is reached. This is an inefficient use of disk space. When reading the data Interbase removes the spaces.

Rather:
create table test(
  id        integer primary key,
  content   BLOB
);

Content is now a pointer to a segment of data stored on disk. The default segment size is 80 (which can be changed), also you are not limited to 512 chars. Now when adding a record of 100 chars as in the previous example Interbase will store the data in 2 segments.(First 80 chars in the first segment next 20 in the second segment)

Blobs datatype were added to the IB functionallity specifically for your type of need.

Regards
Ben:)
0
VitttAuthor Commented:
Great thanks to meikl and Ben...
But there is "TQuery.RecordCount=-1" problem. It's so important for my project... Can i get real RecordCount in this way?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

kretzschmarCommented:
hi vittt,
you can get a properly recordcound, if you use the method tquery1.last or the method tquery.fetchall, because the recordcount-property can only set if are known how much records are retrieved.

but this will slow down your database-perfomance, depending on the amount of records, which will retrieved.

another solution could be to fire a second query, which counts the records with a sql-statement.

why is this so important for you?

meikl
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kretzschmarCommented:
hi vittt,
whats going on?
meikl
0
VitttAuthor Commented:
Hi kretzschmar!
I make it as you advised. It works properly, but slow (.Last and .FetchAll). Unfortunately I cannot use the second query with count because of primary query has CachedUpdates=true.

Thnx and best wishes vittt.
0
kretzschmarCommented:
glad to helped you ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.