dbTalk Databases Forums  

variable-length data

comp.databases.btrieve comp.databases.btrieve


Discuss variable-length data in the comp.databases.btrieve forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Thomas Blum
 
Posts: n/a

Default variable-length data - 03-17-2006 , 01:34 PM






Hi,
how do I work with variable-length data (like 'varchar') in BTrieve? I
know that I must create a database and define a fixed-length part and a
variable-length part of the data. But how do I get the data back (for
example with BTRCALL(BTGETEQUAL,....))? I think, I have to pass the length
of the databuffer to BTRCALL, but what do I have to pass when I don't know
the length of the data I'm looking for?
Best regards
Thomas Blum

--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

Reply With Quote
  #2  
Old   
Bill Bach
 
Posts: n/a

Default Re: variable-length data - 03-17-2006 , 04:43 PM






Simple -- Allocate a data buffer that is large enough to hold the
LARGEST possible record. Pass that size as your Data Buffer Length.

After returning from the call, the Data Buffer Length parameter will
have been changed to the value of the ACTUAL data returned, and that
number of bytes will be in the buffer.

Two caveats:
1) If you are doing this in a loop, be sure to reset the Data Buffer
Length before EACH call to the max buffer size. Otherwise, if you have
a short record followed by a long one, you'll get a Status 22.
2) If you DO get a 22, note that the database will return as many bytes
as it could fit in the buffer space provided. You can increase the
buffer and re-try if you want to. Of course, a Status 22 can also be
an optimization technique -- if you really only want the first 45 bytes
of a record, you can do a Get with a BufLen of 45, then just treat the
22 as a Status 0.
3) If you need to access records greater than 60K or so, you'll need to
access it in Chunks. See the manual for details, as this can get
complicated.
Goldstar Software Inc.
Building on Btrieve(R) for the Future(SM)
Bill Bach
BillBach (AT) goldstarsoftware (DOT) com
http://www.goldstarsoftware.com
*** Chicago: Pervasive Service & Support Class - 03/27/06 ***

Thomas Blum wrote:

Quote:
Hi,
how do I work with variable-length data (like 'varchar') in BTrieve?
I know that I must create a database and define a fixed-length part
and a variable-length part of the data. But how do I get the data
back (for example with BTRCALL(BTGETEQUAL,....))? I think, I have to
pass the length of the databuffer to BTRCALL, but what do I have to
pass when I don't know the length of the data I'm looking for? Best
regards Thomas Blum


Reply With Quote
  #3  
Old   
Leonard
 
Posts: n/a

Default Re: variable-length data - 03-20-2006 , 08:34 AM



There are two ways I can think of off the top of my head.
1) just send in a really large value for the data buffer length. The
absolute maximum is 64k - 1 but for client server overhead worst case
is 53k after overhead.
While that should be good for most records a status 22 will tell you
that it is not big enough. BTW the status 22 indicates that the data
buffer length is not large enough, but the data returned (up to the
data buffer length passed in) is valid.
2) If it does not fit in a single record you would need to implement
the Get Direct/Chunk(23).
http://www.pervasive.com/library/doc...eapi-3-14.html
With the Get Direct/Chunk(23) operation there is no record size
limit*, just keep calling it to get the next chunk until you have the
entire record. *Actually the record size limit is 2GB, hopefully some
other method is used to store that much data than a database engine.

Leonard

On Fri, 17 Mar 2006 20:34:49 +0100, "Thomas Blum"
<Blum_Thomas (AT) nospam (DOT) web.de> wrote:

Quote:
Hi,
how do I work with variable-length data (like 'varchar') in BTrieve? I
know that I must create a database and define a fixed-length part and a
variable-length part of the data. But how do I get the data back (for
example with BTRCALL(BTGETEQUAL,....))? I think, I have to pass the length
of the databuffer to BTRCALL, but what do I have to pass when I don't know
the length of the data I'm looking for?
Best regards
Thomas Blum


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.