MySQL CREATE trigger

Source: Internet
Author: User
Tags mysql create

--  added create trigger yqhl_htjs_b_htjbxx_insert before insert on  table name    for each row    begin    if  (NEW. F_sync_update is null)  or  (NEW. f_sync_update = 0)   then    set new. f_sync_update=null;       --  inserting newly added records into the Operation log table          insert into data_sync_b_operator (t_name, o_type, o_date,  Vkeys)  values (' Table name ', 1, current_timestamp,new. HTDQBH);       end if;end;--  Modify Create trigger yqhl_htjs _b_htjbxx_update before update on  table name   for each rowbeginif  (NEW. F_sync_update is null)  or  (NEW. f_sync_update = 0)   then   --  Insert and update operations, update timestamp f_sync_date=systimestamp and f_ Sync_update=nullset&nBsp NEW. f_sync_update=null;   end if;end;--  Delete Create trigger yqhl_htjs_b_htjbxx_ delete before delete on  Table name   for each row    begin     if  (old. F_sync_update is null)  or  (old. f_sync_update = 0)   then       --  Insert and update operations, update timestamp f_ Sync_date=systimestamp and f_sync_update=null           --   Add the primary key of the delete record to the Operation record table     insert into data_sync_b_operator (T_name, o_type,  o_date, vkeys)  values (' Table name ', 3, current_timestamp,old. HTDQBH);       end if;end;

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

MySQL CREATE trigger

Related Article

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.