IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cannot use on delete cascade


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sriram K

New User


Joined: 17 Feb 2009
Posts: 32
Location: Bangalore

PostPosted: Fri Mar 20, 2009 10:13 am
Reply with quote

I used the below query with ON DELETE CASCADE option to delete rows from all the tables ( Parent & child ).

DELETE FROM ALSR5. table1
WHERE
BOR_SSN = ********* AND
BOR_ACT_SFX = '1' AND
BOR_SEQ_NUM = 01
ON DELETE CASCADE

Here table1 is the parent table and we have got many child tables. The problem here is the table is defined with DELETE RESTRICT option because of which i couldn't able to use ON DELETE CASCADE option. So i got -199 error on spufi.

Let know if there are any other keyword with which we can achieve this.
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Fri Mar 20, 2009 10:20 am
Reply with quote

Sriram,

i think you atr trying to post a new topic
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Thu Mar 26, 2009 2:42 am
Reply with quote

Hi,

DELETE RESTRICT restricts deletion of child table rows whenever a parent row is deleted. In turn you cannot delete any thing. I hope this will not work even in reverse direction of Deleting child table then deleting parent if it is a foreign key with DELETE RESTRICT in both parent and child tables.

The only way would be to disable this for some time and delete needed rows. Then reenable it. Contact your DBA to do this.

Thanks,
Reddy
Back to top
View user's profile Send private message
Raghu navaikulam

Active User


Joined: 27 Sep 2008
Posts: 193
Location: chennai

PostPosted: Fri Mar 27, 2009 12:39 am
Reply with quote

Hi Sriram

Could you please post the entire error message generated by DB2. The SQLCODE -199 says it is purely a syntax error. Can you please check at your shop whether the ON DELETE CASCADE can be used with the DELETE statement. To my knowledge, ON DELETE CASCADE is a RI rule, that can be mentioned with DDL, not DML. Check your DB2 version you are using and also check whether this statement is a valid one for your DB2.

Regards
Raghu
Back to top
View user's profile Send private message
ruodeer

New User


Joined: 06 Jul 2007
Posts: 58
Location: home

PostPosted: Fri Mar 27, 2009 7:06 am
Reply with quote

Hi, I believe
Code:
ON DELETE CASCADE
is kind of syntax of referential constraint, you can not use it in Delete statement, please check DB2 SQL manual.
Back to top
View user's profile Send private message
senthilnathanj

New User


Joined: 31 Jul 2007
Posts: 47
Location: chennai

PostPosted: Fri Mar 27, 2009 3:45 pm
Reply with quote

hi,
SQLCODE -199
Explanation: A syntax error was detected in the statement at the point
where the keyword keyword appears.
For Example,
Create a table COLOR with the Parent table.
Code:
CREATE TABLE COLOR
(
    c_id INTEGER NOT NULL PRIMARY KEY,
    c_desc  CHAR(20) );

Create a Child table OBJECT as mentioned below:
Code:
CREATE TABLE OBJECT
(
  o_id CHAR(2),
  o_desc CHAR(20),
  c_id   INTEGER  REFERENCES  COLOR(c_id) ON DELETE CASCADE);

Code:
DELETE  FROM COLOR  WHERE c_id =2

you can create like this and execute.
Please let me know if any concerns..
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DELETE SPUFI DB2 1
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts How to delete a user's alias from the... JCL & VSAM 11
No new posts Delete file row if blanks in the firs... DFSORT/ICETOOL 5
No new posts volume mass delete RMM JCL & VSAM 2
Search our Forums:

Back to Top