How to determine if insert or update

后端 未结 5 697
庸人自扰
庸人自扰 2020-12-07 00:03

Whenever INSERT is happened in the CUSTOMER table,I need to call the \"StoredProcedure1\"and UPDATE is happend in the CUSTOMER table,I need to call the \"

5条回答
  •  广开言路
    2020-12-07 00:33

    create or replace trigger comp
    before
    insert or delete or update
    on student
    referencing old as o new as n
    for each row
    begin
      if deleting then
               insert into student_backup values
          (:o.studid,:o.studentname,:o.address,:o.contact_no,:o.branch,sysdate);
      end if;
      if inserting then
            insert into student_backup values
          (:n.studid,:n.studentname,:n.address,:n.contact_no,:n.branch,sysdate);
     end if;
      if updating then
           insert into student_backup values
          (:o.studid,:o.studentname,:o.address,:o.contact_no,:o.branch,sysdate);
      end if;
    end comp;
    

提交回复
热议问题