码迷,mamicode.com
首页 > 数据库 > 详细

DB2 触发器的写法及表主键结构的修改

时间:2015-06-05 19:23:29      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:

DROP TRIGGER TR_MONTHLYCLOSING;

CREATE TRIGGER TR_MONTHLYCLOSING NO CASCADE BEFORE
INSERT ON PT_MONTHLYCLOSING REFERENCING NEW AS NEWROW
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
    IF (NEWROW.FLOWNO IS NULL) THEN
        SET NEWROW.FLOWNO = CURRENT DATE;
    END IF;
END

ALTER TABLE DMS."PT_MONTHLYCLOSING"
DROP CONSTRAINT "PK_FLOWNO";

ALTER TABLE DMS."PT_MONTHLYCLOSING"
ADD CONSTRAINT "PK_FLOWNO" PRIMARY KEY (FLOWNO,ACCESS_DATE,MAINTENANCE_CD,SORTING);

 

DB2 触发器的写法及表主键结构的修改

标签:

原文地址:http://www.cnblogs.com/ShaYeBlog/p/4555121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!