MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DB2 v8 - Referential Constraints

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
SMS
Beginner


Joined: 16 Oct 2005
Posts: 53
Topics: 24

PostPosted: Fri Nov 09, 2007 5:54 pm    Post subject: DB2 v8 - Referential Constraints Reply with quote

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
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Fri Nov 09, 2007 9:44 pm    Post subject: Re: DB2 v8 - Referential Constraints Reply with quote

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
View user's profile Send private message
videlord
Beginner


Joined: 09 Dec 2004
Posts: 147
Topics: 19

PostPosted: Sat Nov 10, 2007 6:53 pm    Post subject: Reply with quote

check the manual, SQL reference, you'll get the answer.
Do not build your own SQL
Back to top
View user's profile Send private message
SMS
Beginner


Joined: 16 Oct 2005
Posts: 53
Topics: 24

PostPosted: Mon Nov 12, 2007 10:03 am    Post subject: Reply with quote

If you look into the below URL, it talks about the referential integrity for insert & update. Though it's for version 9, long time back I have read about the insert & update referential constraints in the earlier versions. But I could not find that manual.

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.intro/db2z_db2enforcesreferentialconstraints.htm

Thanks,
SMS
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Mon Nov 12, 2007 12:50 pm    Post subject: Reply with quote

SMS wrote:
If you look into the below URL, it talks about the referential integrity for insert & update. Though it's for version 9, long time back I have read about the insert & update referential constraints in the earlier versions. But I could not find that manual.

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.intro/db2z_db2enforcesreferentialconstraints.htm

Thanks,
SMS


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
View user's profile Send private message
SMS
Beginner


Joined: 16 Oct 2005
Posts: 53
Topics: 24

PostPosted: Mon Nov 12, 2007 3:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group