|Subject||Re: [firebird-support] strlen in retrieved char buffer|
>I traced through the code and discovered theBecause the data returned by query are VARCHAR.
> SQLDA->sqlvar->sqltype is getting changed to 448
> (SQL_VARYING) when the isc_dsql_prepare() is run. By
> setting it back to 453 (SQL_TEXT + 1), I get the
> correct output.
> Can anyone explain why the prepare statement is
> changing the data type?
It is correct behaviour of dsql_prepare(), if you want to change
sqltype, you have to do it after prepare.
Or do not include SQLDA in your prepare() call
(but it would mean you have to fill everything correctly by hand).
Or you can use CAST in your sql query to change returned
datatype from VARCHAR to CHAR.
>> that views are used to access). When I run theIf you force VARCHAR data to be returned as CHAR instead,
>> query and the value is
>> returned, the length of the returned string proceed
>> the actual string.
>> For example, if the Group string is 'UNIT1', the
>> return value comes
>> back '\5\0UNIT1\0\0...'
>> In other queries I run, I get filler blanks (which I
>> would prefer and
>> can easily right-trim).
you will need to read/use correct size of buffer anyway (using sqllen value),
so I do not see much point in what you are trying to do.