Microsoft KB Archive/271852

= BUG: MS Oracle ODBC Driver Truncates Trailing Spaces in Column Name =

Article ID: 271852

Article Last Modified on 12/5/2003

-

APPLIES TO


 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.0
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Open Database Connectivity 2.5
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7

-



This article was previously published under Q271852



SYMPTOMS
When you use Microsoft's Oracle ODBC driver with the ODBC SQLDescribeCol function, incorrect values may be returned for the column name and column name length.



CAUSE
This problem occurs when you have a trailing space in the table's column name. The Microsoft Oracle ODBC driver truncates any trailing spaces when the column information is returned by the SQLDescribeCol function.



RESOLUTION
You can work around this problem in either of the following ways:  Use the SQLColumns ODBC API instead of SQLDescribeCol to retrieve the exact name of the column. SQLColumns returns the correct name, without truncating the trailing spaces.

-or-  You can also query the catalog information from Oracle to retrieve the column name. To do this, use the USER_TAB_COLUMNS table with the following SQL statement: Select COLUMN_NAME from USER_TAB_COLUMNS WHERE TABLE_NAME='TEST' This statement returns the correct column name, including the trailing spaces. 



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Use the ODBC Test program (the Obdcte32.exe file that comes with the Microsoft Data Access Components Software Development Kit) to connect to any Oracle server.  Create a table by using the following commands and script. Call SQLExecDirect to execute the following SQL statement: Create table Test(&quot; Col &quot; VarChar2(10)) </li>  Call SQLExecDirect to execute the following SQL statement: Select * from Test </li>  Call SQLDescribeCol for column number 1. The output window displays the following: SQLDescribeCol: ... Return: SQL_SUCCESS=0 Out: *ColumnName = &quot; col&quot;, *NameLengthPtr = 4, *DataTypePtr = SQL_CHAR=1, *ColumnSizePtr = 10, *DecimalDigits = 0, *NullablePtr = SQL_NULLABLE=1 </li></ol>

NOTE: We have created a column whose name is of length 5. SqlDescribeCol has returned *NameLengthPtr = 4, instead of 5 as expected. Also note that the column name is returned as &quot; col&quot; instead of as &quot; col &quot;. The trailing space has been truncated by the driver.

Additional query words: msorcl32

Keywords: kbbug kboracle kbdatabase kbdriver kbpending KB271852

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.