CREATE OR REPLACE PROCEDURE EXPORTA_VIGENCIA_VOO
(
P_CDFILIAL IN VARCHAR2,
P_CDCIA IN VARCHAR2,
P_NRVOOORI IN VARCHAR2,
P_CDTRECHOORI IN VARCHAR2,
P_NRSEQVOOTRECHODATA IN VARCHAR2,
P_VOOSDEST IN VARCHAR2,
P_CDOPERADOR IN VARCHAR2,
P_NRORG IN NUMBER,
P_NRLISTAERROS OUT NUMBER
)
AS
BEGIN
   FOR CUR_VIGENCIAS IN
   (SELECT V.NRSEQVOOTRECHODATA, V.DTINIVIGENCIA, V.DTFIMVIGENCIA
        FROM VOOTRECHODATA V
       WHERE V.CDFILIAL = P_CDFILIAL
         AND V.CDCIA = P_CDCIA
         AND V.NRVOO = P_NRVOOORI
         AND V.CDTRECHO = P_CDTRECHOORI
         AND VERIF_VALOR_LISTA(TO_CHAR(V.NRSEQVOOTRECHODATA), P_NRSEQVOOTRECHODATA) IS NOT NULL
      ) LOOP
      COPIA_VIGENCIA_VOO(P_CDFILIAL, 
                         P_CDCIA, 
                         P_NRVOOORI, 
                         P_CDTRECHOORI,
                         CUR_VIGENCIAS.NRSEQVOOTRECHODATA, 
                         P_VOOSDEST, 
                         CUR_VIGENCIAS.DTINIVIGENCIA,
                         CUR_VIGENCIAS.DTFIMVIGENCIA,
                         P_CDOPERADOR, 
                         P_NRORG, 
                         P_NRLISTAERROS,
                         'S');
   END LOOP;
END;
/