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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts How do I create a mainframe monitorin... anjali.bisht All Other Mainframe Topics 4 Fri Sep 01, 2017 2:20 pm
This topic is locked: you cannot edit posts or make replies. rexx to create a tso command Bharath Vikraman CLIST & REXX 1 Tue Aug 08, 2017 3:32 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts How do you create Eclipse based dialogs jasorn IBM Tools 0 Thu Aug 03, 2017 5:05 pm

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