create or replace PROCEDURE CENTRO_CUSTODESPESA_493(
   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_CENTRO_CUSTODESPESA IN (SELECT (TO_CHAR(NVL(DTULTATUCCUS,SYSDATE), 'DDMMYYYY')  ||
                                         RPAD(NVL(CDCENTCUST,' '), 28, ' ') ||
                                         RPAD(NVL(NMCENTCUST,' '), 45, ' ')
                                         ) AS DSARQMAG
                                 FROM CENTCUST) LOOP
      V_SEQUNCIAL := NVL(V_SEQUNCIAL,0) +1;
      INSERT INTO ARQMAGNETICO
        (NRORDREGARQ, DSREGARQMAG, NRSEQARQMAG)
      VALUES
        ('09'||LPAD(RTRIM(V_SEQUNCIAL), 8, '0'), C_CENTRO_CUSTODESPESA.DSARQMAG,  P_NRSEQARQMAG);
   END LOOP;
END;
/
-- VERSAO --
BEGIN ATUVEROBJ('CENTRO_CUSTODESPESA_493','5.33.xxx'); END;
/