CONSTRAINT with ON DELETE CASCADE

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
User avatar
diana44
Member
Posts: 1
Joined: Thu Nov 15, 2007 9:42 pm
Location: Honduras

CONSTRAINT with ON DELETE CASCADE

Post by diana44 » Thu Nov 15, 2007 10:07 pm

Hi to everyone:

I?m a real beginner in DB2 and I try to do a CONSTRAINT with ON DELETE CASCADE but it doesn't do what i need to do.
I assume that this constraint allows me to delete a row in the parent table(TABLA1), and the constraint automatically will delete all the dependent rows on the dependent table(TABLA2), or at least thats what I what to do.
The thing is that when I creat this contraint betwen two tables, and I try to delete a row from the parent table, I can't and it gives me an error. Something like the parent table isn't valid for the operation of delete.
I creat the constraint with this code:

Code: Select all

ALTER TABLE TABLA2
	ADD CONSTRAINT 
	FOREIGN KEY( CAMPO1 ) 
	REFERENCES TABLA1 ( CAMPO3 ) 
	ON DELETE CASCADE 
	ON UPDATE NO ACTION ; 
I want to know if I'm doing something wrong on the code or if I have to do something else for the constraint works.
I will appreciate any help.
Saludos :D

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others