Subject reading varchar length via API
Author Francesco Lamonica
Hash: SHA1

Hi, i'm developing an app using firebird 1.03 and the qt libraries.
I am stuck while retrieving data after a select. I've read the manuals (IB6
dox) but still i think i am mising something.
I've got a bunch of VARCHAR(1000) fields, obviously they are not completely
full so when i retrieve them i get lot of garbage that makes the app go nuts.

say we have
table tablename
id integer not null,
name varchar(100),
primary key(id)

after the initialization phase (attach,start_transaction,preparing the XSQLDA
i do

then there should be the coerction of data
should i do it? i think so since i have to allocate memry for the sqldata
but then i'll allocate as much memory as needed by the CHAR(100) not the
Also the allocation of memory for the sqlind should be done?

So, where should i look for the _real_ length of the retrieved field? i read
that it is stored in the first 2 bytes of the char* but trying to read them
ended with ridiculously high numbers.

Can u point me to a tutorial/piece of code where this topic is covered with a
lil bit more of detail? (i would not mind if u r willing to give me a
ready-made solution ;-) )

P.S. on the dox the test to see if we're encountering a NULL value is
if ((var->sqltype & 1) && (*(var->sqlind)=-1))

shouldnt it be

if ((var->sqltype & 1) && (*(var->sqlind)==-1))

thanks a lot
- --
Francesco Lamonica: f DOT lamonica AT tin DOT it

PGP Fingerprint: 5870 92BA 8DFF 1ACF DE2E B94D 46EC 5505 7C64 4EF1
Favourite quote: There's no spoon
Version: GnuPG v1.2.2 (GNU/Linux)