home clear 64x64
en blue 200x116 de orange 200x116 info letter User
suche 36x36
Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IC74859 Status: Closed

THE KEYCOLUSE.COLSEQ COLUMN NOT SHOWING THE CORRECT COLUMN SEQUENCE IN THE
FOREIGN KEY IN V9.1

product:
DB2 FOR LUW / DB2FORLUW / 910 - DB2
Problem description:
The KEYCOLUSE.COLSEQ column not showing the correct column 
sequence in the foreign key if an existing unique index is used 
for the primary key (SQL0598W) and the ordering of the columns 
between the index and the primary key don't match. 
 
 
 
For example consider the following- 
create db test ; 
connect to test ; 
 
 
CREATE TABLE  SCHEMA.A   ( 
          EDUCATIONORG_ID                 CHAR(3) NOT NULL , 
          COURSEOFFERING_ID               CHAR(5) NOT NULL , 
          ADMISSIONROUND_ID               CHAR(10) NOT NULL 
) IN  USERSPACE1  ; 
 
 
 
CREATE UNIQUE INDEX SCHEMA.UNIINDEX ON SCHEMA.A 
(COURSEOFFERING_ID ASC, EDUCATIONORG_ID ASC, ADMISSIONROUND_ID 
ASC) ALLOW REVERSE SCANS; 
 
 
 
ALTER TABLE SCHEMA.A  ADD CONSTRAINT PRIMKEY PRIMARY KEY ( 
ADMISSIONROUND_ID, EDUCATIONORG_ID, COURSEOFFERING_ID); 
 
CREATE TABLE SCHEMA.B ( 
      ADMISSIONROUND_ID       CHAR(10) NOT NULL, 
      EDUCATIONORG_ID         CHAR(3) NOT NULL, 
      COURSEOFFERING_ID       CHAR(5) NOT NULL, 
 
) IN USERSPACE1 ; 
 
 
 
ALTER TABLE SCHEMA.B ADD CONSTRAINT FRKEY FOREIGN KEY 
(ADMISSIONROUND_ID, EDUCATIONORG_ID,COURSEOFFERING_ID) 
REFERENCES SCHEMA.A ON DELETE CASCADE ON UPDATE RESTRICT ; 
 
................................................................ 
..................................... 
Note-For table A the Primary key PRIMKEY internally uses unique 
index UNIINDEX(SQL0598W) as the columns in the 
unique index and priamry key are the same,though the order of 
the column is different. 
 
Now run the following select statement to retrieve the column 
sequence in the primary and foreign key. 
 
SELECT  substr(K.TABNAME,1,25) tabname, substr(K.COLNAME,1,25) 
colname, substr(K.CONSTNAME,1,18) constname, K.COLSEQ FROM 
SYSCAT.KEYCOLUSE K WHERE K.TABSCHEMA = 'SCHEMA' AND K.TABNAME IN 
('B','A') ; 
 
This should ideally show the following order .Which is the case 
for V8 . 
 
................................................................ 
..................... 
TABNAME                   COLNAME                   CONSTNAME 
COLSEQ 
------------------------- ------------------------- 
------------------ ------ 
A   ADMISSIONROUND_ID         PRIMKEY    1 
A   EDUCATIONORG_ID           PRIMKEY    2 
A   COURSEOFFERING_ID         PRIMKEY    3 
B   ADMISSIONROUND_ID         FRKEY                   1 
B   EDUCATIONORG_ID           FRKEY                   2 
B   COURSEOFFERING_ID         FRKEY     3 
 
  6 record(s) selected. 
................................................................ 
........................ 
 
But in V9.X we get the following. 
................................................................ 
........................ 
TABNAME                   COLNAME                   CONSTNAME 
COLSEQ 
------------------------- ------------------------- 
------------------ ------ 
A   ADMISSIONROUND_ID         PRIMKEY    1 
A   EDUCATIONORG_ID           PRIMKEY    2 
A   COURSEOFFERING_ID         PRIMKEY    3 
B   COURSEOFFERING_ID         FRKEY                   1 
B   EDUCATIONORG_ID           FRKEY                   2 
B   ADMISSIONROUND_ID         FRKEY     3 
 
  6 record(s) selected. 
 
................................................................ 
............................. 
 
Here the column sequence in the foreign key is shown to be 
COURSEOFFERING_ID(1),EDUCATIONORG_ID(2),ADMISSIONROUND_ID(3), 
while the actual sequence as per the 
DDL statement is 
ADMISSIONROUND_ID(1),EDUCATIONORG_ID(2),COURSEOFFERING_ID(3) . 
 
This APAR fixes this anomaly and displays the column sequence 
properly. 
 
It is importnat to note that this anomay happens only if both 
the following conditions are satisfied. 
1)There is a pre existing unique index on the parent table with 
same columns as in the priamry key 
2)The order of the column is not same as that in the primary 
key. 
 
If there is no preexisting unique index on the parent table we 
won't see this behaviour. 
Also this issue doesn't happen in V8.
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* All DB2 users                                                * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* THE KEYCOLUSE.COLSEQ COLUMN NOT SHOWING THE CORRECT COLUMN   * 
* SEQUENCE IN THE FOREIGN KEY IN V9.1 .                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Upgrade to DB2 V9.1 FP11 to avail a fix.                     * 
****************************************************************
Local Fix:
NA.
available fix packs:
DB2 Version 9.1 Fix Pack 11  for Linux, UNIX and Windows
DB2 Version 9.1 Fix Pack 12  for Linux, UNIX and Windows

Solution
First fixed in DB2 V9.1 FP11
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
07.03.2011
09.12.2011
09.12.2011
Problem solved at the following versions (IBM BugInfos)
9.1.FP11
Problem solved according to the fixlist(s) of the following version(s)
9.1.0.11 FixList