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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.