• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 988
  • Last Modified:

DB2 FOREIGN KEY name DOES NOT CONFORM TO THE DESCRIPTION OF THE PRIMARY KEY OF TABLE table name

Hi ,
Need help on execution of FK Relation ship in Z/OS
I have Two table Table_A and Table_B
Create table TABLE_A(Primary_no bigint not null,Primary_Value varchar(25)) ;
Create table TABLE_B(Secondary_no bigint not null,Parent_Primary_No Bigint,Secondary_Value varchar(25));

ALTER TABLE TABLE_B ADD CONSTRAINT FKEY8 FOREIGN KEY (Parent_Primary_No)      REFERENCES TABLE_B (Primary_No) ON DELETE RESTRICT;
I am getting error
DB2 FOREIGN KEY name DOES NOT CONFORM TO THE DESCRIPTION OF THE PRIMARY KEY OF TABLE table name
So I checked the difference
in TABLE_B column  (Parent_Primary_No) is nullable
I have ran same in UDB it is working ....but i need this column nullable.
0
SAKETHREDDY
Asked:
SAKETHREDDY
1 Solution
 
Dave FordSoftware Developer / Database AdministratorCommented:

I could be missing something here, but it doesn't look like you defined a primary key on TABLE_A.

Also, you foreign key constraint seems to be pointing to itself. I think you meant to point to TABLE_A.

HTH,
DaveSlash
0
 
momi_sabagCommented:
Dave is right
you should try
ALTER TABLE TABLE_B ADD CONSTRAINT FKEY8 FOREIGN KEY (Parent_Primary_No)      REFERENCES TABLE_A (Primary_No) ON DELETE RESTRICT;

there should be no problem in zos having the foreign key column contain nulls,
just make sure the column you reference (primary_no in table_a) has either a primary key or a unique key defined on it
0
 
SAKETHREDDYAuthor Commented:
thanks for your help.
i find the solution in my R&D
In Z/Os we need to create Index , before creating the Primary key, Then if we ran the FK relationships it will not give above error.
In UDB on Windows , when i am creating table and Primary key , it is creating Index on primary cols, so it is not giving error in local system

 
0
 
Computer101Commented:
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now