Subject Re: [firebird-support] reading varchar length via API
Author William L. Thomson Jr.
On Tue, 2003-08-19 at 19:33, Francesco Lamonica wrote:

> 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 ;-) )

Ok it's been a bit since I wrote this and I have been in Java world. I
would need to refresh my memory for an explanation but I will try a
little.

case SQL_VARYING :
xsqlda->sqlvar[i].sqltype = SQL_TEXT;
// This is where the mem allocation occurs
// and length of data is determined
xsqlda->sqlvar[i].sqldata = new char[xsqlda->sqlvar[i].sqllen+3];
memset(xsqlda->sqlvar[i].sqldata,' ',xsqlda->sqlvar[i].sqllen);
xsqlda->sqlvar[i].sqldata[xsqlda->sqlvar[i].sqllen] = '\0';
break;

Hopefully that will get you going in the right direction. Of course I am
using C++. If you are using C you will need to tweak the code a bit.

You get the length via xsqlda->sqlvar[i].sqllen

I believe that is covered in the docs. You may want to look in the
ApiGuide under Data Structures starting on Page 401.

> 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))

If you are referring to the IB 6 docs available in pdf format keep in
mind they are beta docs. There are many errors, some that drove me nutz.
I ended up purchasing a copy of the IB media pack, or what ever it is
called per Helen's advice.

There is very little diff, but at least in the docs I paid for the
examples do not contain mistakes. Worth the $ to not waste my time on
examples that contain errors. :)


--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios, Inc.
http://www.obsidian-studios.com