Link to home
Start Free TrialLog in
Avatar of JDCam
JDCam

asked on

DB2 Trigger

I'm trying to create a trigger to update one field off another within the same table.  Something is wrong with the syntax.
Can someone help?


CREATE TRIGGER CUST_TLO_APPT_FLAG
AFTER UPDATE OF DELIVERY_APPT_REQ ON TLORDER
REFERENCING NEW AS N OLD AS O
FOR EACH ROW
MODE DB2SQL
BEGIN ATOMIC
  IF O.DELIVERY_APPT_REQ = 'False' and N.DELIVERY_APPT_REQ = 'True' THEN SET USER9 ='Y' ;
  END IF;
  IF O.DELIVERY_APPT_REQ = 'True' and N.DELIVERY_APPT_REQ = 'False' THEN SET USER9 ='' ;
  END IF;
END@

Open in new window

Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Hi JD,

I believe that you want a BEFORE trigger here.


Kent
Avatar of JDCam
JDCam

ASKER

This is the error we are getting:
I don't understand as we are only using one table here.

-- Failure!!!
-- [IBM][CLI Driver][DB2/NT64] SQL0203N  A reference to column "USER9" is ambiguous.  LINE NUMBER=8.  SQLSTATE=42702
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JDCam

ASKER

That worked.
Thanks