CREATE OR REPLACE TRIGGER LOG_SUP_PRODCOMP
AFTER DELETE
ON PRODCOMP  FOR EACH ROW
DECLARE
  V_DSREMOTEADDR VARCHAR2(15);
  V_DSREMOTEHOST VARCHAR2(15);
  V_DSSERVERRDM  VARCHAR2(20);
  V_DSSERVMETHOD VARCHAR2(30);
  V_DSREMOTEOPER VARCHAR2(12);
  V_DESC         VARCHAR2(500);
  V_ITPESQ       VARCHAR2(40);
  V_NMOPERADOR   VARCHAR2(40);
  V_IDTIPOOPER   VARCHAR2(1);
BEGIN
/* IDTIPOOPER - '1' - Inclusao, '2' - Alteracao, '3' - Exclusao*/
   V_DESC       := '';
   V_ITPESQ     := '';
   V_NMOPERADOR := '';
   V_IDTIPOOPER := '';
   NMUSUARIO(V_NMOPERADOR);
   WEBTUNNING(V_DSREMOTEADDR,
              V_DSREMOTEHOST,
              V_DSSERVERRDM,
              V_DSSERVMETHOD,
              V_DSREMOTEOPER);
   V_DESC   := 'Comprador ' || '' || :OLD.CDOPERADOR || ' ' ||
               'Produto '   || '' || :OLD.CDPRODUTO;
   V_ITPESQ := :OLD.CDOPERADOR||:OLD.CDPRODUTO;
   V_IDTIPOOPER := '3';
   V_DESC := SUBSTR(V_DESC, 1, 300);
   INSERT INTO LOGOPERA
      (NMTABELA,
       DTOPERACAO,
       NMRESPOPER,
       IDTIPOOPER,
       DSOPERACAO,
       CDPESQITEM,
       DSRDMUSUOPER,
       DSENDUSUOPER,
       DSNMUSUOPER,
       DSMETUSUOPER,
       CDORESPOPER)
   VALUES
      ('PRODCOMP',
       SYSDATE,
       NVL(V_NMOPERADOR,' '),
       V_IDTIPOOPER,
       V_DESC,
       V_ITPESQ,
       V_DSSERVERRDM,
       V_DSREMOTEADDR,
       V_DSREMOTEHOST,
       V_DSSERVMETHOD,
       V_DSREMOTEOPER);
END;
/