Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> UTL_FILE package. Need Help!
Hi,
I have written a procedure using the UTL_FILE package to write data from a table to a text file. Unfortunately, each row of the data I am writting is pretty long, more than the allowed 1023 buffer.
I have tried using UTL_FILE.FFLUSH in such a way that the procedure would write part of the row then flush the buffer and then write the last part of the row before continuing to the next row. This is not working.
The only way I have been able to get the program to work is with the code below, where 'buffervariable1-4' are the four different variables that make up the entire row, each of them contains close to 1000 chars.
By doing it the way I have it below the file is created but after each CLOSE command the program inserts a NEWLINE so that my one row of data is actually on fours different rows.
begin
UTL_FILE.PUTF(filehandle, buffervariable1); UTL_FILE.FCLOSE(filehandle); filehandle := UTL_FILE.FOPEN('c:\utlfiles','svcordrs.txt','a'); UTL_FILE.PUTF(filehandle, buffervariable2); UTL_FILE.FCLOSE(filehandle); filehandle := UTL_FILE.FOPEN('c:\utlfiles','svcordrs.txt','a'); UTL_FILE.PUTF(filehandle, buffervariable3); UTL_FILE.FCLOSE(filehandle); filehandle := UTL_FILE.FOPEN('c:\utlfiles','svcordrs.txt','a'); UTL_FILE.PUTF(filehandle, buffervariable4); UTL_FILE.FCLOSE(filehandle); filehandle := UTL_FILE.FOPEN('c:\utlfiles','svcordrs.txt','a'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR ' || to_char(SQLCODE) || ' ' || SQLERRM); null; end; -----------------------------------------------------
Now, I have tried it this way but it hasn't worked:
begin
UTL_FILE.PUTF(filehandle, buffervariable1); UTL_FILE.FFLUSH(filehandle); UTL_FILE.PUTF(filehandle, buffervariable2); UTL_FILE.FFLUSH(filehandle); UTL_FILE.PUTF(filehandle, buffervariable3); UTL_FILE.FFLUSH(filehandle); UTL_FILE.PUTF(filehandle, buffervariable4); UTL_FILE.FFLUSH(filehandle); UTL_FILE.NEW_LINE(filehandle,1); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR ' || to_char(SQLCODE) || ' ' || SQLERRM); null; end; -----------------------------------------------------
PLEASE HELP!!!!!!!
Thanks,
Manny Otero
Developer / DBA
SLi Lighting Solutions
manny.otero_at_bigfoot.com
Received on Tue Jul 13 1999 - 10:14:25 CDT