Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q271852

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. 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.
  2. Create a table by using the following commands and script. Call SQLExecDirect to execute the following SQL statement:
    Create table Test(" Col " VarChar2(10))
    					
  3. Call SQLExecDirect to execute the following SQL statement:
    Select * from Test
    					
  4. Call SQLDescribeCol for column number 1. The output window displays the following:
    SQLDescribeCol:
    ...
    Return:	SQL_SUCCESS=0
    Out: *ColumnName = " col", *NameLengthPtr = 4, *DataTypePtr = SQL_CHAR=1, *ColumnSizePtr = 10, *DecimalDigits = 0, *NullablePtr = SQL_NULLABLE=1
    					
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 " col" instead of as " col ". The trailing space has been truncated by the driver.

↑ Back to the top


Keywords: kbbug, kbdatabase, kbdriver, kboracle, kbpending, KB271852

↑ Back to the top

Article Info
Article ID : 271852
Revision : 5
Created on : 12/5/2003
Published on : 12/5/2003
Exists online : False
Views : 495