create or replace PROCEDURE PLANOCONTA_DIAGERAL_492(
   P_DTINICIAL    IN NOTAFISCAL.DTEMISSAO%TYPE,
   P_DTFINAL      IN NOTAFISCAL.DTEMISSAO%TYPE,
   P_NRSEQARQMAG  IN ARQMAGNETICO.NRSEQARQMAG%TYPE)
AS
   V_SEQUNCIAL NUMBER;
BEGIN
   FOR C_PLANOCONTA_DIAGERAL IN (SELECT (TO_CHAR(DTULTATUCCTB, 'DDMMYYYY')  ||
                                         RPAD(NVL(CDCONTCTBL,' '), 28, ' ') ||
                                         NVL(NVL(IDTIPOCONT,' '), ' ')      ||
                                         RPAD(NVL(CDCONTANTE,' '), 28, ' ') ||
                                         RPAD(NVL(NMCONTCTBL,' '), 45, ' ')
                                         ) AS DSARQMAG
                                 FROM CONTCTBL
                                 ORDER BY CDCONTCTBL) LOOP
      V_SEQUNCIAL := NVL(V_SEQUNCIAL,0) +1;
      INSERT INTO ARQMAGNETICO
        (NRORDREGARQ, DSREGARQMAG, NRSEQARQMAG)
      VALUES
        ('07'||LPAD(RTRIM(V_SEQUNCIAL), 8, '0'), C_PLANOCONTA_DIAGERAL.DSARQMAG,  P_NRSEQARQMAG);
   END LOOP;
END;
/
-- VERSAO --
BEGIN ATUVEROBJ('PLANOCONTA_DIAGERAL_492','5.33.xxx'); END;
/