If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > delete records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-21-04, 06:04
Azrina Azrina is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Unhappy delete records

DBA2187E Failed to delete selected row(s).

com.ibm.db.DataException: A database manager error occurred. : [IBM][CLI Driver][DB2/NT] SQL0532N A parent row cannot be deleted because the relationship "DB2SRV.A_VBHDR.FK_A_VBH_BCTBN" restricts the deletion. SQLSTATE=23504

HELPPPPP?
urgent
TQ
Reply With Quote
  #2 (permalink)  
Old 01-21-04, 06:17
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: delete records

Type in

db2 "? sql0532n"

on your command line for help


or

download message reference manual from the db2 website www.ibm.com/db2/library

Cheers
Sathyaram


Quote:
Originally posted by Azrina
DBA2187E Failed to delete selected row(s).

com.ibm.db.DataException: A database manager error occurred. : [IBM][CLI Driver][DB2/NT] SQL0532N A parent row cannot be deleted because the relationship "DB2SRV.A_VBHDR.FK_A_VBH_BCTBN" restricts the deletion. SQLSTATE=23504

HELPPPPP?
urgent
TQ
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 01-21-04, 06:31
Azrina Azrina is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Re: delete records

how to solve my problem? please help me....

Quote:
Originally posted by sathyaram_s
Type in

db2 "? sql0532n"

on your command line for help


or

download message reference manual from the db2 website www.ibm.com/db2/library

Cheers
Sathyaram
Reply With Quote
  #4 (permalink)  
Old 01-22-04, 17:44
aloz aloz is offline
Registered User
 
Join Date: May 2003
Location: San Juan, PR
Posts: 18
Azrina, suppose you have 2 tables:
ACCOUNT (Parent Table)
ACCOUNT-TRANSACTION (Dependent Table, because every transaction must be associated to one account. To ensure this relation, an referential integrity rule without "cascade" option has been defined).
To delete one row from ACCOUNT table, all the dependents rows in ACCOUNT_TRANSACTION must be deleted first. With "cascade" option, when parent row is deleted, all dependents rows are automaticly deleted too.

I hoped this help you.

Regards, ALF.
Reply With Quote
  #5 (permalink)  
Old 01-22-04, 23:19
prabhu22 prabhu22 is offline
Registered User
 
Join Date: Jan 2004
Posts: 10
Azrina,
You could try this.

drop the foreign key constraint first.
"ALTER TABLE <child table name> DROP FOREIGN KEY DB2SRV.A_VBHDR.FK_A_VBH_BCTBN"

recreate it with "on delete cascade"
"ALTER TABLE <child table name> ADD CONSTRAINT DB2SRV.A_VBHDR.FK_A_VBH_BCTBN FOREIGN KEY (column names) REFERENCES <parent table name> (column names) ON DELETE CASCADE"

Now, whenever the parent table data is deleted, the corresponding data in the child table would also be deleted.

Hope this helps.
__________________
thanks,
prabhu.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On