0

We can make foreign keys very easily using SQL. But is there any way to declare foreign key using DDS?

Buck Calabro
  • 7,558
  • 22
  • 25
Vikash Shukla
  • 55
  • 1
  • 2
  • 12
  • I think no special keyword in DDS. Without SQL normally use command ADDPFCST, with Constraint type *REFCST. You can read more by searching "Referential Integrity" – lamLam Sep 19 '14 at 09:05
  • It can't be done with DDS alone. It must be combined with CL (or SQL). – user2338816 Sep 20 '14 at 23:57

1 Answers1

1

As IamLam pointed out, DDS doesn't directly support constraints in the source; you have to use ADDPFCST after the fact.

I'm assuming you don't have a change management system. In that case, you could do one of two things

Switch to SQL DDL - there's basically no difference between an SQL created table and DDS created file. IBM actually provides a utility to generate SQL DDL for an object regardless of rather or not it was created with DDS or DDL in the first place.

Use a pre-compiler for your DDS. One open source one I've heard about is Alan Campin's COMPILE http://think400.dk/downloads.htm

Actually you could use either of the above with a CMS also, but if you had a CMS you probably wouldn't be asking the question as it should take care of creating the constraint when the file is changed.

Charles
  • 21,637
  • 1
  • 20
  • 44