UTL_FILE max line size problem
David Seibold, July 16, 2001 - 5:18 pm UTC
This article had the solution for our write error.
UTL_FILE exception handler
Jeremy Becker, August 13, 2002 - 2:06 pm UTC
Thanks for the tip. Glad I could find it on the site, as I left my copy of your book at home. Very functional exception handling for UTL file operations and makes me rethink just 'copping out' and using WHEN OTHERS all the time.
OK
Ram, May 11, 2004 - 8:21 am UTC
Dear Tom,
I have a text file with some 10 lines of characters.I would
like to insert a string into the second line.I used the
*fseek* function but I am getting the "file read error".
After opening the file,I used
sql> utl_file.fseek(v_handle,2,0);
Could you please tell me how to insert a string at
appropriate lines with in a file?
Please do reply.
May 11, 2004 - 9:57 am UTC
think about how files work.
In order to "insert a second line", you would need to move ALL of the data in the file from the beginning of the new second line.
Say you have a file like this:
How now brown cow
The fox is going to run away
With a spoon
or something like that
If you wanted a "new line two with 15 characters", you would need to rewrite the file as so:
How now brown cow
_______________ <<<=== 15 spaces
The fox is going to run away
With a spoon
or something like that
you need to physically shove the file "down".
So, what you need to do is
a) read the first line from existing file
b) write first line to new file
c) write NEW second line to new file
d) read/write rest of lines from existing file to new file
If fseek worked -- all you would do is end up overwriting what ever was there. files are not rows in a table! the are just big globs of data.
UTL_FILE to print one line more than 1023 char in a file
Kishor, October 23, 2017 - 6:38 am UTC
Hi Tom,
I am trying to print a data into a file which contanins more than 1023+ characters in it. But it's ending with UTL_FILE.WRITE_ERROR.If the data is less than 1020, then the file is generating. Could u please help me in creating the txt file which have single line with more than 1100 chars.
Thanks,
Kishor
October 24, 2017 - 2:18 am UTC
That is the default. You can extend this to 32k, eg
l_log_file := UTL_FILE.fopen('mydir','myfile.dat','W',32767);