View previous topic :: View next topic
|
Author |
Message |
princegaurav
New User
Joined: 08 Dec 2005 Posts: 9
|
|
|
|
Hello,
I have created a table which has a primary key comprising of 2 columns say col1 and col2.
I have created 2 unique index one on primary key(col1 and col 2) and another on col1.
Now I am creating another table where I have to use col1 of first table as a foreign key in new table but I am geting an error (sqlcode 538).
If I refer to the below link then I can see if I have unique index defined in the parent table on a particular column then I can use it as a foreign key in the other table. publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z9.doc.codes%2Fsrc%2Ftpc%2Fn538.htm
I have tried to drop the primary key to see if then I am able to create the table with foreign key as col1 but the problem persists.
Could you please help me on this.
Regards,
Gaurav |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Can you show the DDL's for both tables , Indexes and Alter statements to define PK and FK. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
just curious : why would you have PK (col1,col2) when IX(col1) is unique ? |
|
Back to top |
|
|
|