Microsoft KB Archive/304394

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

Article ID: 304394

Article Last Modified on 12/3/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 Q304394



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.



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.



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.



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 (&quot;DEMO&quot;) 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
  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));  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. Click Catalog, and then click SQLPrimaryKeys to invoke SQLPrimaryKeys. 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

 Click Results, and then click Get Data All. In the result set, notice that KEY_SEQ appears as &quot;2, 3, 1&quot; instead of the expected &quot;1,2,3&quot;.</ol>

<div class="references_section">