Db2的触发器实例

drop TRIGGER NDJJ.TEST_EMPRCPD
@
CREATE TRIGGER NDJJ.TEST_EMPRCPD AFTER  INSERT  ON NDJJ.ndjj_EMPIMPDATA  REFERENCING  NEW AS newrow  NEW_TABLE AS ndjj_empimpdata_empscoregrd  FOR EACH ROW  MODE DB2SQL WHEN ( newrow.Svtyp_b='1')
BEGIN ATOMIC
update ndjj_empwageadj a set (a.Emp_scoregrd_b) =
--cast(newrow.Impvalue as char(1))
case when newrow.Impvalue=1 then 'A'
     when newrow.Impvalue=2 then 'B'
     when newrow.Impvalue=3 then 'C'
     when newrow.Impvalue=4 then 'D'
     when newrow.Impvalue=5 then 'E'
else '-' end
where a.pk_year=newrow.pk_year
and a.Pk_corp=newrow.Pk_corp
and a.emp_branchcode=newrow.emp_branchcode
and a.pk_year=(select pk_year from ndjj_setyear) ;
END
@

把以上的文本存为 name.sql;然后执行db2cmd--> db2 -td@ -f name.sql就可以了

你可能感兴趣的:(sql,C++,c,db2,C#)