CREATE OR REPLACE TRIGGER VROBRIGCPFNOTA_PARAVEND
BEFORE INSERT
ON PARAVEND FOR EACH ROW
DECLARE
  V_SGESTADO       VARCHAR2(2);
  V_VROBRIGCPFNOTA FLOAT;
BEGIN
  SELECT SGESTADO
    INTO V_SGESTADO
    FROM ENDEFILI    
   WHERE IDTPENDEFILI = 'P'
     AND CDFILIAL     = :NEW.CDFILIAL;
   
  IF V_SGESTADO = 'PE' THEN
    V_VROBRIGCPFNOTA := 1000;  
  ELSIF V_SGESTADO = 'MG' THEN 
    V_VROBRIGCPFNOTA := 3000;  
  ELSIF V_SGESTADO = 'TO' THEN
    V_VROBRIGCPFNOTA := 3000;  
  ELSIF V_SGESTADO = 'SE' THEN
    V_VROBRIGCPFNOTA := 5000;  
  ELSE 
    V_VROBRIGCPFNOTA := 10000;  
  END IF;
  
  :NEW.VROBRIGCPFNOTA := V_VROBRIGCPFNOTA;
  
END;
/