Oracle Create triggers

Source: Internet
Author: User

Create or replace trigger [email protected]@  before insert or  update or delete on @[email protected]  referencing old as  old_emp new as new_emp  for each rowbegin  --when modified by the application, F_ Sync_update=null or f_sync_update=0, you do not need to update the f_sync_date  timestamp at this time, and you do not need to record delete records   if  (: New_emp. F_sync_update is null)  or  (: New_emp. f_sync_update = 0)  then    --Insert and update operations, update timestamp f_sync_date=systimestamp and F_SYNC_ update=null    if inserting or updating then       select systimestamp, null        into :new_ Emp. F_sync_date, :new_emp. f_sync_update        from dual;    end  If;    if inserting then      --Insert the newly added record into the Operation log table       insert into  DATA_SYNC_B_OPERATOR         (T_name, o_type, o_date,  vkeys)       values         (' @[ Email protected] ',  1, systimestamp, @[email protected]);     end  if;    if deleting then      -- Add primary key of Delete record to Operation record table       insert into DATA_SYNC_B_OPERATOR          (T_name, o_type, o_date, vkeys)        values         (' @[email protected] ', 3,  Systimestamp, @[email protected]);     end if;  end if;end  [email protected]@;

This article is from the "write-free" blog, please be sure to keep this source http://7156680.blog.51cto.com/7146680/1790837

Oracle Create triggers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.