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.
SAKETHREDDYAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.