[unixODBC-support] Extra spaces in the query result

Nick Gorham nick.gorham at easysoft.com
Wed Jun 28 09:10:22 BST 2006


Nagesh Sharvari-A21337 wrote:

>Hello,
>	I am using Oracle driver from easy soft and the problem is, when
>I execute stored procedures, in the varchar type OUT parameters, extra
>spaces are added at the end.  For Example, if the buffer size is 30, and
>the value length is only 10, then 20 extra spaces are getting added
>after the actual value. 
>
>This is making my validation scripts to fail. 
>
>Here is an example of bind command I am using:
>
>char msmdn[30];
>bzero(msmdn, sizeof(msmdn));
>#define MSMDN_COLSIZE 30
>SQLINTEGER     strlenMdn = SQL_NTS;
>SQLBindParameter(stmt,
>                 3,
>                 SQL_PARAM_OUTPUT,
>                 SQL_C_CHAR,
>                 SQL_VARCHAR,
>                 (SQLUINTEGER)MSMDN_COLSIZE,
>                 0,
>                 (SQLCHAR *)msmdn,
>                 sizeof(msmdn),
>                 &strlenMdn);
>
>
>Here the column size is 30bytes and even the buffer size is 30 bytes.
>But Since this is a varchar, the actual size of the value is only 10
>bytes. ODBC is filling extra spaces at the end of the buffer.
>
>Please help me solve this.
>  
>
Hi.

This is because Oracle allows nulls to be embedded in a string, so the 
driver returns the length Oracle reports. There is an option to make the 
driver behave like you may expect for a Varchar, add

VarcharTrimTrailingSpaces       = 1

to the DSN ini entry.

BTW, this list is for unixODBC support, the Easysoft driver isn't part 
of unixODBC, As it happens I can answer for both, but the correct place 
for Easysoft driver questions is support at easysoft.com

-- 
Nick Gorham
Easysoft Limited
http://www.easysoft.com, http://www.unixODBC.org




More information about the unixODBC-support mailing list