更新时间:2021-12-21 06:33:34
是的!
这是来自iSeries DB2 SQL编程的一些示例代码(全部用SQL编写)手动(通常会在LUW之后运行一些版本):
Here's some example code (All in SQL) from the iSeries DB2 SQL Programming manual (which tends to run a few versions behind LUW):
CREATE TRIGGER TransactionBeforeTrigger BEFORE INSERT ON TransactionTable
REFERENCING NEW AS new_row
FOR EACH ROW MODE DB2ROW
BEGIN
DECLARE newmonth SMALLINT; -- Here's the decleration
SET newmonth = MONTH(new_row.DateOfTransaction);
IF newmonth < 4 THEN
SET new_row.FiscalQuarter=3;
ELSEIF newmonth < 7 THEN
SET new_row.FiscalQuarter=4;
ELSEIF newmonth < 10 THEN
SET new_row.FiscalQuarter=1;
ELSE
SET new_row.FiscalQuarter=2;
END