Need to update same table on update using trigger in DB2

375 views Asked by At

Below is table which I need to auto update based on condition domain id=parent

If the purchase date has been updated then on update trigger will fire and update domain id 101, 102. I am using the trigger below but unsuccessfully. How can I fix it?

Create Trigger Domain_U
    AFTER UPDATE ON DOMAIN REFERENCING NEW AS NEW_ROW
WHEN (PARENT IS NOT NULL)
Begin Atomic
    If Domain id = Parent Then
    Update Domain Set PurchaseDate=New_Row.PurchaseDate WHERE STATE='ACTIVE'
    End If;
END

Example input data:

DOMAINID  DOMAINNAME       EXPIRYDATE  IP           PURCHASEDATE  PARENT  STATE
100       www.rida.com     2015-08-05  10.20.222.1  2015-01-05            ACTIVE
101       www.ridatab.com              10.20.222.2                100     ACTIVE
102       www.grt.com                  10.0.222.3                 100     ACTIVE
0

There are 0 answers