View previous topic :: View next topic |
Author |
Message |
SMS Beginner
Joined: 16 Oct 2005 Posts: 53 Topics: 24
|
Posted: Fri Nov 09, 2007 5:54 pm Post subject: DB2 v8 - Referential Constraints |
|
|
Hi,
I tried to create the referential constraint as follows.
FIELD1 INTEGER NOT NULL WITH DEFAULT
CONSTRAINT D_FIELD1
REFERENCES T1.TABLE1 (FIELD1)
ON DELETE CASCADE ON INSERT RESTRICT,
But I am getting the below error.
DSNT408I SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD INSERT. TOKEN KEY WAS
EXPECTED
When I remove the 'ON INSERT RESTRICT' it works fine. Please help me on this. I wonder whether DB2 V8 supports ON INSERT / UPDATE referential constraints.
Really this forum was very useful. Couple of times the response I got from here was very helpful at the crucial times. Thanks.
Regards,
SMS |
|
Back to top |
|
|
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Fri Nov 09, 2007 9:44 pm Post subject: Re: DB2 v8 - Referential Constraints |
|
|
SMS wrote: | Hi,
I tried to create the referential constraint as follows.
FIELD1 INTEGER NOT NULL WITH DEFAULT
CONSTRAINT D_FIELD1
REFERENCES T1.TABLE1 (FIELD1)
ON DELETE CASCADE ON INSERT RESTRICT,
But I am getting the below error.
DSNT408I SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD INSERT. TOKEN KEY WAS
EXPECTED
When I remove the 'ON INSERT RESTRICT' it works fine. Please help me on this. I wonder whether DB2 V8 supports ON INSERT / UPDATE referential constraints.
Really this forum was very useful. Couple of times the response I got from here was very helpful at the crucial times. Thanks.
Regards,
SMS |
I have never heard of an INSERT/UPDATE referential constraint, is that something new with DB2 V8? |
|
Back to top |
|
|
videlord Beginner
Joined: 09 Dec 2004 Posts: 147 Topics: 19
|
Posted: Sat Nov 10, 2007 6:53 pm Post subject: |
|
|
check the manual, SQL reference, you'll get the answer.
Do not build your own SQL |
|
Back to top |
|
|
SMS Beginner
Joined: 16 Oct 2005 Posts: 53 Topics: 24
|
|
Back to top |
|
|
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Mon Nov 12, 2007 12:50 pm Post subject: |
|
|
If you READ the topic at the URL above you will see that the insert & update rules are build into the constraint, only the delete rule has any options. |
|
Back to top |
|
|
SMS Beginner
Joined: 16 Oct 2005 Posts: 53 Topics: 24
|
Posted: Mon Nov 12, 2007 3:22 pm Post subject: |
|
|
I already read that topic. Actually I found an example with ON DELETE RESTRICT ON UPDATE RESTRICT, so I thought there were some explicit Insert / Update constraints and was trying to find the syntax. But now only I realize that I wrongly read the example from IBM UDB for Iseries.
Now I am clear. I can create triggers for my requirements. Thanks for your help.
Regards,
SMS |
|
Back to top |
|
|
|
|