CREATE OR REPLACE PROCEDURE RECONCILIACAO_CNC(P_SEQESTABELEC IN NUMBER,
                                              P_DTINICIAL IN DATE,
                                              P_DTFINAL IN DATE)
AS
BEGIN
   FOR C_ESTABELEC IN
      (SELECT DISTINCT R.NRESTABELEC
         FROM RETVENDAADQ R
        WHERE NRESTABELEC = NVL(P_SEQESTABELEC, NRESTABELEC)
          AND R.DTVENDA BETWEEN P_DTINICIAL AND P_DTFINAL) LOOP
      CONCILIACAO_CNC(C_ESTABELEC.NRESTABELEC, P_DTINICIAL, P_DTFINAL);
   END LOOP;
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('RECONCILIACAO_CNC','6.10.000'); END;
/
