Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Please help with this trigger
Hi,
I am trying to create a trigger that will keep 2 tables in sync. I have a master table that is maintenanced (added, changed or deleted) and I would like to keep a smaller version of that table in sync with it. If a row is added to the master, I would like to add a row to the other table, if one is deleted from the master, I would like to delete the same row from the other and any changes to the master, I would like to apply (if the same column exists) to the other table.
Below is what I have written so far, but it is obviously not correct. Can someone please show me what I need to change so that it works correctly...I appreciate it...thanks!!! Andy
create or replace trigger update_supplier
before insert or delete or update on frt.supplier_master
for each row
begin
if inserting then
insert into frt.supplier (abv, supplier, customer, code, division) values (:new.abv, :new.customer_vendor, :new.customer_vendor_no, :new.code, :new.division); elsif deleting then delete from frt.supplier where abv = :new.abv; elsif updating then update frt.supplier set abv = :new.abv, supplier = :new.customer_vendor, customer = :new.customer_vendor_no, code = :new.code, division= :new.division;