Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    6

    Unanswered: 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,

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    yes .. why not this delete in the after trigger ?
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •