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

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);

 

posted @ 2015-06-05 17:11  沙耶  阅读(784)  评论(0编辑  收藏  举报