Subject Re: [firebird-support] strlen in retrieved char buffer
Author Kurt Federspiel
Hi, Ivan.

Thanks for all that information...

I am trying to pull the Group names out of the table,
and this is the only query that I have processed that
changed SQLTYPE to was a unique

The data in the DB is stored in VARCHAR fields. Would
you suggest processing them as SQL_VARYING or
SQL_TEXT? I have a lot of these type of queries, and
there is no going back after I make this decision.

Thanks again...

--- Ivan Prenosil <Ivan.Prenosil@...> wrote:

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

Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.