create or replace TRIGGER ERX.IB_NCPDP_MSG_TRG
    BEFORE INSERT OR UPDATE ON ERX.INBOUND_NCPDP_MSG
    FOR EACH ROW
DECLARE
    xml_status NUMBER;
BEGIN
IF UPDATING THEN
  :NEW.UPDATED_DATE := SYSDATE; 
ELSE
  :NEW.CREATED_DATE := SYSDATE;
   IF :NEW.INBOUND_NCPDP_MSG_ID IS NULL THEN
    :NEW.INBOUND_NCPDP_MSG_ID := IB_NCPDP_MSG_ID_SEQ.NEXTVAL;
   END IF; 
END IF;
END;
/
