Db2 trigger example

Source: Internet
Author: User

-- Create table statement create table wangzstable (idintegernot null, NAMEVARCHAR (20) not null, AGEVARCHAR (20) not null, STATUSVARCHAR (10), createtimestamp, UPDATETIMETIMESTAMP, SENDTIMETIMESTAMP ); select * from wangzsTable; insert into WANGZSTABLE (id, name, age) values (1, 'hangzhous1 ', '26 '); update WANGZSTABLE set status = '2' where id = 1; -- update specific status = 4 drop trigger "WANGZS_UPDATE "; create trigger WANGZS_UPDATE after update of 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 updates specific idDROP TRIGGER "WANGZS_UPDATE "; create trigger WANGZS_UPDATE after update of 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 Fig new as newrow for each row mode DB2SQLBEGIN ATOMIC update WANGZSTABLE set CREATETIME = current timestamp where id = NEWROW. id; END;

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.