Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> don't want trigger error to block insert
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
![]() |
![]() |