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 script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-10, 07:26
ratheeshknair ratheeshknair is offline
Registered User
 
Join Date: Jan 2009
Posts: 153
Delete script

Hi Experts,

I am having a customer linked to many tables like card,account,bank etc .How can i delete all the related data of a particular customer in single query?

Can anyone pleasse give me some hint ?

TIA
Reply With Quote
  #2 (permalink)  
Old 01-11-10, 08:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You cannot do it is a "single" statement--unless all of your RI is setup up to do it for you. You can however do it in an atomic block of statements:

--Turn off autocommit if it is on
Delete from all child tables in the proper order
delete from parent table
commit
--Turn on autocommit if applicable

Andy
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