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.

FIX: Oracle Driver Doesn't Sort SQLPrimaryKeys Result Set by Key Sequence


View products that this article applies to.

Symptoms

If you call the SQLPrimaryKeys command, and the SchemaName is set to a valid schema name, the Microsoft Oracle Driver does not order the result set that is returned from ODBC Test as expected.

↑ Back to the top


Resolution

To resolve this problem, obtain the latest service pack for Microsoft Data Access Components 2.6. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
300635 INFO: How to Obtain the Latest MDAC 2.6 Service Pack
To work around this problem, use Oracle's ODBC Driver.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft Data Access Components 2.6 Service Pack 2.

↑ Back to the top


More information

According to the ODBC specifications, the result set that SQLPrimaryKeys returns should sort by TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ. Although the Microsoft Oracle Driver sorts by catalog and schema followed by table name, the key sequence is left unordered. This problem only occurs when a schema is specified in the SQLPrimaryKeys call ("DEMO") in the following example. If DEMO is not specified but is left as null, the result set is returned in the correct order.

Steps to Reproduce Behavior

  1. From SQL *PLUS, use the following code to create a table:
    create table my_table(col1 int, col2 int, col3 int, primary key(col2, col3,col1));
    					
  2. Open ODBC Test, click Conn from the menu, and then click Full connect. Select the DSN that uses the Microsoft Oracle Driver, and type the User Id and Password.
  3. Click Catalog, and then click SQLPrimaryKeys to invoke SQLPrimaryKeys.
  4. In the TableName drop-down list box, click my_table. In the SchemaName drop-down list box, click a valid schema name, and then click OK to invoke the command. You receive the following error message:
    Return: SQL_SUCCESS=0
  5. Click Results, and then click Get Data All. In the result set, notice that KEY_SEQ appears as "2, 3, 1" instead of the expected "1,2,3".

↑ Back to the top


References

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
271852 BUG: MS Oracle ODBC Driver Truncates Spaces in Column Name

↑ Back to the top


Keywords: kbnosurvey, kbarchive, kbbug, kbfix, kbmdac260sp2fix, kboracle, KB304394

↑ Back to the top

Article Info
Article ID : 304394
Revision : 4
Created on : 12/29/2014
Published on : 12/29/2014
Exists online : False
Views : 323