Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Unable to create a foreign key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
princegaurav

New User


Joined: 08 Dec 2005
Posts: 9

PostPosted: Tue Nov 06, 2012 6:24 pm    Post subject: Unable to create a foreign key
Reply with quote

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. http://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
View user's profile Send private message

gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Nov 07, 2012 10:29 am    Post subject:
Reply with quote

Can you show the DDL's for both tables , Indexes and Alter statements to define PK and FK.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Nov 12, 2012 3:03 pm    Post subject:
Reply with quote

just curious : why would you have PK (col1,col2) when IX(col1) is unique ?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
No new posts copy SEQ to PDS and create stats steve-myers JCL & VSAM 7 Thu Apr 27, 2017 1:15 am
No new posts Unable to catalog a gdg dataset resid... Shovan JCL & VSAM 7 Fri Mar 24, 2017 2:24 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us