Subject | Re: [firebird-support] reading varchar length via API |
---|---|
Author | William L. Thomson Jr. |
Post date | 2003-08-20T01:05:42Z |
On Tue, 2003-08-19 at 19:33, Francesco Lamonica wrote:
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.
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
> Can u point me to a tutorial/piece of code where this topic is covered with aOk it's been a bit since I wrote this and I have been in Java world. I
> lil bit more of detail? (i would not mind if u r willing to give me a
> ready-made solution ;-) )
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 isIf you are referring to the IB 6 docs available in pdf format keep in
> if ((var->sqltype & 1) && (*(var->sqlind)=-1))
>
> shouldnt it be
>
> if ((var->sqltype & 1) && (*(var->sqlind)==-1))
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