Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Need better approach to create a sort... Vamshi Veludandi DFSORT/ICETOOL 8 Thu Mar 08, 2018 5:59 pm
No new posts Can we create REXX ouput in an Excel ... upendrasri CLIST & REXX 3 Wed Jan 17, 2018 8:19 pm
No new posts Unable to send mail with SMTP commands harsh.saxena579 JCL & VSAM 10 Tue Dec 12, 2017 1:58 pm
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts unable to set RC = 4 when empty file migusd SYNCSORT 1 Tue Nov 21, 2017 1:21 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us