Subject | Re: [firebird-support] reading varchar length via API |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2003-08-20T05:12:32Z |
On 20 Aug 2003 at 1:33, Francesco Lamonica wrote:
Where 2 is sizeof(short int) - length of length.
can set sqlind to an address of any appropriate variable.
is stored as int16 in first two bytes of buffer. More exactly buffer
for varchar contain PARAMVARY structure after fetch.
like ibpp.
them.
SY, Dimitry Sibiryakov.
>isc_dsql_prepare(status_vector,&trans,&stmt,0,query,1,NULL);If you wish. I prefer not to do it.
>isc_dsql_describe(status_vector,&stmt,1,out_sqlda);
>
>then there should be the coerction of data
>should i do it?
> i think so since i have to allocate memry for theAt first, the buffer for varchar must have length = sqllen + 2.
>sqldata but then i'll allocate as much memory as needed by the
>CHAR(100) not the VARCHAR(100).
Where 2 is sizeof(short int) - length of length.
> Also the allocation of memory for theYes. But you don't have to allocate dynamic memory for that. You
>sqlind should be done?
can set sqlind to an address of any appropriate variable.
>So, where should i look for the _real_ length of the retrieved field?If you don't do datatype coercing, length of actual varchar string
>i read that it is stored in the first 2 bytes of the char* but trying
>to read them ended with ridiculously high numbers.
is stored as int16 in first two bytes of buffer. More exactly buffer
for varchar contain PARAMVARY structure after fetch.
>Can u point me to a tutorial/piece of code where this topic is coveredLook at existing libraries. I can't remember exact name, something
>with a lil bit more of detail? (i would not mind if u r willing to
>give me a ready-made solution ;-) )
like ibpp.
>P.S. on the dox the test to see if we're encountering a NULL value isSure, it should. Any documentation consists mistakes. It is one of
>if ((var->sqltype & 1) && (*(var->sqlind)=-1))
>
>shouldnt it be
>
>if ((var->sqltype & 1) && (*(var->sqlind)==-1))
> ^^^
them.
SY, Dimitry Sibiryakov.