DB2 Trigger Example

Source: Internet
Author: User

--Create TABLE wangzstable (Idintegernot null, Namevarchar () not NULL, Agevarchar () is not NULL, Statusvarchar (10 ), Createtimetimestamp, Updatetimetimestamp, Sendtimetimestamp); select * from Wangzstable;insert to Wangzstable (id,n Ame,age) VALUES (1, ' wangzs1 ', ' n '); update wangzstable set status= ' 2 ' where id=1;--update updates a specific state Status=4drop TRIGGER " Wangzs_update ";  CREATE TRIGGER Wangzs_update after UPDATE of the STATUS on wangzstable referencing old as Oldrow NEW as NEWROW for each ROW MODE db2sqlbegin ATOMIC IF (NEWROW.  Status= ' 4 ') then update wangzstable set updatetime=current TIMESTAMP where id=newrow.id; END IF; End;--update Update specific Iddrop TRIGGER "Wangzs_update";  CREATE TRIGGER Wangzs_update after UPDATE of the STATUS on wangzstable referencing old as Oldrow NEW as NEWROW for each ROW MODE db2sqlbegin ATOMIC Update wangzstable set updatetime=current TIMESTAMP where id=newrow.id; End;--insertdrop TRIGGER "Wangzs_insert"; CREATE TRIGGER Wangzs_insert after INSERT on WangzsTABLE referencing NEW as NEWROW for each ROW MODE db2sqlbegin ATOMIC update wangzstable set createtime=current times tamp where id=newrow.id; END;

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.