Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
3.2.2
-
None
-
Windows 32 bit
Description
I have defined PRIMARY KEY on table, which consists of 4 columns.
When I call ODBC API SQLPrimaryKeys these 4 columns are returned in order how they appear in table definition, not in primary key definition.
SQLPrimaryKeys returns 4 rows, where 5th column - KEY_SEQ - return:
2,
5,
6,
9
But https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlprimarykeys-function states, that:
KEY_SEQ: "Column sequence number in key (starting with 1)"
So KEY_SEQ should be sequence in key not in table ...
Simplified example:
create table test (
c1 int not null,
c2 int not null,
c3 int not null,
c4 int not null,
CONSTRAINT PK_test PRIMARY KEY (c3,c2)
);
Call to SQLPrimaryKeys returns these two rows:
#1: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY
#2: COLUMN_NAME=c3, KEY_SEQ=3, PK_NAME=PRIMARY
But should return:
#1: COLUMN_NAME=c3, KEY_SEQ=1, PK_NAME=PRIMARY
#2: COLUMN_NAME=c2, KEY_SEQ=2, PK_NAME=PRIMARY