Pular para o conteúdo
Visualizando 4 posts - 1 até 4 (de 4 do total)
  • Autor
    Posts
  • #97229
    mpvargas
    Participante

      Caros Amigos,
      Alguem tem algum modelo de procedure para gerar TXT… gostaria de uma opção para colocar separador.
      Obrigado

      #97244
      mpvargas
      Participante

        CRIEI A PROCEDURE ABAIXO, PARA GERAR UM ARQUIVO TXT
        ESTÁ DANDO ERRO NO ; DO WLINHA (|| ; ||)
        ALGUM AMIGO PODERIA ME AJUDAR.
        OBRIGADO.

        Create or Replace procedure GERATXT as
        file_handle utl_file.file_type;
        CURSOR CUR_TESTE is
        select CAMPO_1, CAMPO_2, CAMPO_4
        from MSIGA.TESTE;
        reg_teste CUR_TESTE%ROWTYPE;
        wlinha varchar2(120);
        wnreg number := 0;

            BEGIN
        file_handle := UTL_FILE.FOPEN ('/logs/diretorios/utl_teste', 'teste.txt', 'w');
        OPEN CUR_TESTE;
        loop
               fetch CUR_TESTE into reg_teste;
               exit when CUR_TESTE%NOTFOUND;
                    wlinha := reg_teste.campo_1 || ; || reg_teste.campo_2;
                    wlinha := wlinha || ; || reg_teste.campo_4;
               utl_file.put_line(file_handle,wlinha);
               wnreg := wnreg + 1;
        end loop;
        
        UTL_FILE.FCLOSE(file_handle);
        close CUR_TESTE;
        
        dbms_output.put_line ('Num. registros gravados =' || to_char(wnreg));
        
             end;
        
        #97245
        Ishii
        Participante

          Olá,

          Faltou aspas simples…


          Create or Replace procedure GERATXT as
          file_handle utl_file.file_type;
          CURSOR CUR_TESTE is
          select CAMPO_1, CAMPO_2, CAMPO_4
          from MSIGA.TESTE;
          reg_teste CUR_TESTE%ROWTYPE;
          wlinha varchar2(120);
          wnreg number := 0;

          BEGIN
          file_handle := UTL_FILE.FOPEN ('/logs/diretorios/utl_teste', 'teste.txt', 'w');
          OPEN CUR_TESTE;
          loop
          fetch CUR_TESTE into reg_teste;
          exit when CUR_TESTE%NOTFOUND;
          wlinha := reg_teste.campo_1 || ';' || reg_teste.campo_2;
          wlinha := wlinha || ';' || reg_teste.campo_4;
          utl_file.put_line(file_handle,wlinha);
          wnreg := wnreg + 1;
          end loop;

          UTL_FILE.FCLOSE(file_handle);
          close CUR_TESTE;

          dbms_output.put_line ('Num. registros gravados =' || to_char(wnreg));

          end;

          []s Ishii

          #97254
          mpvargas
          Participante

            Valeu ishii
            Obrigado pela ajuda

          Visualizando 4 posts - 1 até 4 (de 4 do total)
          • Você deve fazer login para responder a este tópico.