CREATE OR REPLACE FUNCTION SPED_BLOCO1_FOS(
   P_NRSEQARQMAG  IN ARQMAGNETICO.NRSEQARQMAG%TYPE ) RETURN NUMBER
AS
   V_CONTREG1     NUMBER;
BEGIN
   /* ABERTURA DO BLOCO 1 */
   V_CONTREG1 := NVL(V_CONTREG1,0) + 1;
   INSERT INTO ARQMAGNETICO
     (NRORDREGARQ, DSREGARQMAG, NRSEQARQMAG)
   VALUES
     ('80'||LPAD(RTRIM(V_CONTREG1), 8, '0'), '|1001'|| '|' ||'1'|| '|', P_NRSEQARQMAG);


   /* ENCERRAMENTO DO BLOCO 1 */
   V_CONTREG1 := NVL(V_CONTREG1,0) + 1;
   INSERT INTO ARQMAGNETICO
     (NRORDREGARQ, DSREGARQMAG, NRSEQARQMAG)
   VALUES
     ('81'||LPAD(RTRIM(V_CONTREG1), 8, '0'), '|1990'|| '|' ||V_CONTREG1|| '|' , P_NRSEQARQMAG);

   RETURN(V_CONTREG1);
END;
/

-- VERSAO --
BEGIN ATUVEROBJ('SPED_BLOCO1_FOS','5.11.000'); END;
/