Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need a little help with an update trigger (DB2)

Status
Not open for further replies.

craving94509

Technical User
Sep 28, 2012
5
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top