CREATE OR REPLACE TRIGGER TRGCARGA_FORNECEDOR_PGTO
AFTER INSERT OR UPDATE OR DELETE ON CCORFORN FOR EACH ROW
BEGIN
   IF INSERTING THEN
      UPDATE USR_CARGA_FORNECEDOR
      SET TX_BANCO   = :NEW.CDBANCFORN,
          TX_AGENCIA = :NEW.CDAGENFORN,
          TX_CONTA   = :NEW.CDCCORFORN,
          OP_PAGTO   = ''
      WHERE TX_CGC = SUBSTR(:NEW.CDFORNECED, 2, 20);
   ELSIF UPDATING THEN
      UPDATE USR_CARGA_FORNECEDOR
      SET TX_BANCO   = :NEW.CDBANCFORN,
          TX_AGENCIA = :NEW.CDAGENFORN,
          TX_CONTA   = :NEW.CDCCORFORN,
          OP_PAGTO   = ''
      WHERE TX_CGC = SUBSTR(:OLD.CDFORNECED, 2, 20);
   END IF;
END;
/


-- VERSAO --
BEGIN ATUVEROBJ('TRGCARGA_FORNECEDOR_PGTO','4.11.033'); END;
/

