Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

utl_file.put_line suddenly stops writing

Status
Not open for further replies.

TheBoyMonkey

Programmer
Nov 24, 2003
11
FR
I'm writing two CSV files using utl_file, using a number of packages.

The first file is written with the correct number of records. However, the second file stops being written to halfway through creation. No exceptions occur in the code - in fact, the code continues to execute perfectly.

It's as if the line:

utl_file.put_line(file, outputline);

stops having any effect, for some reason.

Sorry, I'm aware this is a little vague, but I'm wondering if anyone has come across this problem before or has any tips as to what may be causing this.

Thanks for any time,
Tom.
 
Monkey,

If this had happened to me, I would create a second text file to which I would write "progress" messages [using "utl_file.put_line(file2, message);"], and then place this command at strategic points in your code. This would confirm whether or not you are reaching the execution points in your code, and it would isolate whether there is some sort of a general problem with "write" functionality. Once you have isolated the problem, then your remove (or comment out) the "troubleshooting" write messages.

Let us know what you find.
 
IS it possible that you are running out of disk space while writing the 2nd file?
 
Santa, dbtoo2001,

Thanks for the replies. Here's an update:

I have used a second output file to track the execution of the code. Unfortunatley, the code executes as expected. If I print the contents of the message into the debug file, the line before I want to write to the output file, the DebugFile contains exactly what I want it to:

For example:

utl_file.put_line(DebugFile, message);
-- message contains correct text (i.e. "value1, value2, value3")
utl_file.put_line(OutputFile, message);
-- message is not inserted into OutputFile.

The only difference at this point between the files is the DebugFile is .txt, while the OutputFile is .csv.

That's confusing enough, but if I add another 'test' line to the output file after every 'message' line, then IT WILL print out the whole set of records.

e.g. utl_file.put_line(OutputFile, message);
utl_file.put_line(OutputFile, 'TEST');


More confusing still, if I hardcode a string (again, say, 'test') to the end of the message, it will print more records than at first, but not the whole set.

e.g. utl_file.put_line(OutputFile, message||'TEST');

I'll keep plugging away at this.....any more help or suggestions very gratefully received.

Thanks,
TBM.

 
I seemed to have solved this - more down to a schoolboy error on my part.

It appears that the put_line doesn't write each line one by one, but rather must cache them and add a set of lines to a file at intervals. The last set wasn't getting written to the file as I was forcing a return somewhere else in my code, which wasn't allowing the file to close, but still allowed the debug file to do so.

The behaviour with the 'test' string added to the end of message is still a little inexplicable, but I'm sure it has to do with buffer lengths or somesuch.

Either way, I've got the results I'm after.

Thanks for your time earier,
TBM.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top