Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> don't want trigger error to block insert

don't want trigger error to block insert

From: Sarah Officer <officers_at_aries.tucson.saic.com>
Date: Wed, 14 Jul 1999 13:01:18 -0700
Message-ID: <378CEC8E.180DFAC7@aries.tucson.saic.com>


I created an insert trigger on one table so that whenever a record is inserted, it causes a record to be inserted into another table. It is possible that the record already exists in the second table, so inserting again violates a uniqueness constraint in table2. This causes the insert into the original table to fail.

How can I write my trigger so that it will insert the record if it can, but it won't cause failure if the insert to table2 fails?

Here's my trigger

CREATE TRIGGER table1_insert_trigger
  AFTER INSERT ON table1
  FOR EACH ROW
  WHEN(new.master_flag = '1')
  BEGIN
    insert into table2(id, filename, category, description)     select :new.id, :new.table1_filename, 'image', 'image: ' || s.longname

    from table3 s
    where s.id = :new.id;
  END;
/

Thanks,

Sarah Officer
officers_at_aries.tucson.saic.com Received on Wed Jul 14 1999 - 15:01:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US