Thursday, August 17, 2017

where exists clause

UPDATE CMG_PPA_CONTRACT_HEADER_TBL  C
SET C.PUBLISHER_NAME = (SELECT V.VENDOR_NAME FROM PO.PO_VENDORS V WHERE V.VENDOR_ID=C.PUBLISHER_ID)
, C.LAST_UPDATE_DATE=TRUNC(SYSDATE)
WHERE
EXISTS
(
    SELECT * FROM PO.PO_VENDORS V
    WHERE V.VENDOR_ID=C.PUBLISHER_ID
    AND   V.VENDOR_ID=1337
    AND   V.VENDOR_NAME !=C.PUBLISHER_NAME
    AND   V.VENDOR_NAME NOT LIKE '%TERMINATE%'
    )
;

COMMIT;

No comments:

Post a Comment