CREATE OR REPLACE
TRIGGER USR_ATU_REPROVA_ITEMSOLI
BEFORE INSERT ON ITEMSOLI
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_IDTIPLAN     VARCHAR2(1);
BEGIN
   WEBTUNNING(V_DSREMOTEADDR,
              V_DSREMOTEHOST,
              V_DSSERVERRDM,
              V_DSSERVMETHOD,
              V_DSREMOTEOPER);
   :NEW.IDSOLIAPROV := 'S';
   IF V_DSSERVERRDM LIKE 'rdmLancaSoliCmp%' THEN
      SELECT NVL(MAX(IDTIPLAN), 'M')
        INTO V_IDTIPLAN
        FROM SOLICITA
       WHERE CDFILLANCA   = :NEW.CDFILLAN
         AND CDFILSOLI    = :NEW.CDFILSOLI
         AND NRSOLICMP    = :NEW.NRSOLICMP;
      IF V_IDTIPLAN = 'M' THEN
         :NEW.IDSOLIAPROV := 'N';
      END IF;
   END IF;
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('USR_ATU_REPROVA_ITEMSOLI','6.05.XXX'); END;
/
