T Mai 2002, S. 30, 'Neue Trigger-Funktionen unter V5R1'
T Bundle Version 1.0
M SAMPLE01   TXT        '02Mai         Neue Trigger-Funktionen unter V5R1'
W SAMPLE01   Verwendung einer neuen Korrelationsvariable
W SAMPLE01   
W SAMPLE01   CREATE TRIGGER big_spenders  
W SAMPLE01     AFTER INSERT ON expenses
W SAMPLE01     REFERENCING NEW AS n
W SAMPLE01     FOR EACH ROW   MODE DB2ROW
W SAMPLE01     WHEN (n.totalamount > 10000)
W SAMPLE01        INSERT INTO travel_audit 
W SAMPLE01               VALUES(n.empno, n.emplname, n.deptno, n.totalamount, 
W SAMPLE01                      n.enddate);
E SAMPLE01   
M SAMPLE02   TXT        '02Mai         Neue Trigger-Funktionen unter V5R1'
W SAMPLE02   Verwendung einer Transitionstabelle
W SAMPLE02   
W SAMPLE02   CREATE TRIGGER accounttrigger
W SAMPLE02     AFTER UPDATE ON accounts
W SAMPLE02     REFERENCING NEW_TABLE AS newtable
W SAMPLE02     FOR EACH STATEMENT MODE DB2SQL
W SAMPLE02    BEGIN
W SAMPLE02          DECLARE chgcnt INT;
W SAMPLE02          SET chgcnt = (SELECT count(*) FROM newtable);
W SAMPLE02    
W SAMPLE02          INSERT INTO account_changes
W SAMPLE02               VALUES('I',CURRENT TIMESTAMP,CURRENT USER, chgcnt);
W SAMPLE02    END
E SAMPLE02   
M SAMPLE03   TXT        '02Mai         Neue Trigger-Funktionen unter V5R1'
W SAMPLE03   Verwendung der SET-Anweisung
W SAMPLE03   
W SAMPLE03   CREATE TRIGGER order_completion
W SAMPLE03     BEFORE INSERT orders
W SAMPLE03     REFERENCING NEW AS n
W SAMPLE03     FOR EACH ROW MODE DB2ROW
W SAMPLE03    BEGIN
W SAMPLE03          SET n.ord_state = UPPER(n.state);
W SAMPLE03          CALL GenOrderNumber(n.ord#);
W SAMPLE03    END
E SAMPLE03   
M SAMPLE04   TXT        '02Mai         Neue Trigger-Funktionen unter V5R1'
W SAMPLE04   Trigger auf Spaltenebene mit SIGNAL-Anweisung
W SAMPLE04   
W SAMPLE04   CREATE TRIGGER salarycheck
W SAMPLE04      BEFORE UPDATE ON emp
W SAMPLE04      REFERENCING NEW AS n
W SAMPLE04      FOR EACH ROW MODE DB2ROW
W SAMPLE04      BEGIN   
W SAMPLE04          DECLARE maxsalary INTEGER;
W SAMPLE04          SET maxsalary = (SELECT max(salary) FROM
W SAMPLE04               jobdescript 
E SAMPLE04   
