› Fóruns › SQL e PL/SQL › Procedure para gerar TXT com separador › Procedure para gerar TXT com separador
9 de dezembro de 2010 às 8:26 pm
#97244
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;