Subject | How do you trim fetched char/varchar column? |
---|---|
Author | Jeff Lynn |
Post date | 2006-04-13T14:51:18Z |
In the same test query I ran:
select id, name from Staff;
with sqlda defined as:
pSqlda->sqlvar[1].sqldata = (char *)&name;
pSqlda->sqlvar[1].sqltype = SQL_TEXT + 1;
pSqlda->sqlvar[1].sqlind = &nameFlag;
where name is declared as char(64).
What I got is:
id: 10 name: Amy Ambrose
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠e
id: 110 name: Barbara Betty
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠e
I tried using trim function to trim the returned name but that didn't
fix it.
If only I know the fetched data length, then I can physically trim the
returned string by inserting a 0x00 at the proper length.
In other commercial databse APIs that I used, the pSQLDA->sqllen
contains the actual fetched data length returned. But in Firebird,
this field returns the max. size of the column.
Any idea?
jml
select id, name from Staff;
with sqlda defined as:
pSqlda->sqlvar[1].sqldata = (char *)&name;
pSqlda->sqlvar[1].sqltype = SQL_TEXT + 1;
pSqlda->sqlvar[1].sqlind = &nameFlag;
where name is declared as char(64).
What I got is:
id: 10 name: Amy Ambrose
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠e
id: 110 name: Barbara Betty
╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠╠e
I tried using trim function to trim the returned name but that didn't
fix it.
If only I know the fetched data length, then I can physically trim the
returned string by inserting a 0x00 at the proper length.
In other commercial databse APIs that I used, the pSQLDA->sqllen
contains the actual fetched data length returned. But in Firebird,
this field returns the max. size of the column.
Any idea?
jml