Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle create trigger

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Create or replace trigger DATA_SYNC_@TABLE@ before insert or update or delete on @ TABLE@ 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 does not need to update the F_SYNC_DATE timestamp or delete records if (: new_emp.F_SYNC_UPDATE is null) or (: new_emp.F_SYNC_UPDATE = 0) then-insert and update operations Update timestamps 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 newly added records into the operation record table insert into DATA_SYNC_B_OPERATOR (t_name, o_type, o_date, VKEYS) values ('@ TABLE@', 1, systimestamp, @ INSERTVAL@); end if If DELETING then-add the primary key to delete the record to the operation record table insert into DATA_SYNC_B_OPERATOR (t_name, o_type, o_date, VKEYS) values ('@ TABLE@', 3, systimestamp, @ UPDATEVAL@); end if;end if;end DATA_SYNC_@TABLE@

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report