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 > Before Trigger Restrictions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-10, 20:03
gourmet gourmet is offline
Registered User
 
Join Date: Feb 2010
Posts: 6
Before Trigger Restrictions

I read that "BEFORE triggers cannot modify the database"

Does this mean that Delete Statement shall not work with Before Triggers ?

Example:

Create Trigger delete_ROW_t1 NO cascade Before update of full_cat on CUST
referencing old as oldrow New as Newrow for each row mode db2sql
when (Newrow.full_cat = 1)
Begin Atomic
delete from C_PROD where id_cust = newrow.id_cust
End;

I am not able to execute the above statement. Is this because DELETE is not allowed with Before Trigger?

Please explain.

Thanks,
Reply With Quote
  #2 (permalink)  
Old 02-17-10, 03:28
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
yes .. why not this delete in the after trigger ?
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 02-17-10, 03:29
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
Yes, you can't use DELETE with a BEFORE trigger.
If you try, the create trigger will fail with sqlcode = -797 / -20100

Only an AFTER trigger can modify data.
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