Subject Re: [firebird-support] strlen in retrieved char buffer
Author Ivan Prenosil
>I traced through the code and discovered the
> SQLDA->sqlvar[0]->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?

Because the data returned by query are VARCHAR.
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 the
>> 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).

If you force VARCHAR data to be returned as CHAR instead,
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.

Ivan
http://www.volny.cz/iprenosil/interbase/