craving94509
Technical User
I am hoping someone can help with a DB2 trigger I am trying to write?
After update of workorder.status = 'APPR' I would like to update the lr_cpstatus of any records in same table = 'PENDING'
where the updated workorder.wonum = workorder.parent
and workorder.lr_cpstatus is null
and lr_rectype = 'CA'
I started with this but it will not compile.
_______________________________________________
CREATE TRIGGER RIGSIGHT.LR_COMMSTATUS_T
BEFORE UPDATE ON RIGSIGHT.WORKORDER
REFERENCING
OLD AS O
NEW AS N
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
IF N.STATUS = 'APPR'
THEN
UPDATE WORKORDER a
SET LR_CPSTATUS = 'PENDING'
WHERE EXISTS
(SELECT *
FROM WORKORDER b
WHERE b.PARENT = a.WONUM
AND b.LR_CPSTATUS IS NULL
AND b.LR_RECTYPE = 'CA');
END IF
END
Many thanks for any ideas.
DB2 version: 10010100
Build: special_30422
O/S: Linux
After update of workorder.status = 'APPR' I would like to update the lr_cpstatus of any records in same table = 'PENDING'
where the updated workorder.wonum = workorder.parent
and workorder.lr_cpstatus is null
and lr_rectype = 'CA'
I started with this but it will not compile.
_______________________________________________
CREATE TRIGGER RIGSIGHT.LR_COMMSTATUS_T
BEFORE UPDATE ON RIGSIGHT.WORKORDER
REFERENCING
OLD AS O
NEW AS N
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
IF N.STATUS = 'APPR'
THEN
UPDATE WORKORDER a
SET LR_CPSTATUS = 'PENDING'
WHERE EXISTS
(SELECT *
FROM WORKORDER b
WHERE b.PARENT = a.WONUM
AND b.LR_CPSTATUS IS NULL
AND b.LR_RECTYPE = 'CA');
END IF
END
Many thanks for any ideas.
DB2 version: 10010100
Build: special_30422
O/S: Linux