Until now we have seen how to read and write text files from within PL/SQL. This section simply gives you a few more tips on writing text files efficiently.
Everyone by now would know what the “utl_file.put_line” is doing. It simply adds a new line to the text file. In fact, it types the entire line that we asked into the text file and also writes a “carriage return line feed” character as well. Put simply, the “carriage return line feed” character is very similar to the character of the “enter” key, when you press it in Notepad.
We also have another option we can use to write into the text file, which is “utl_file.put.” It is very similar to the “utl_file.put_line” except that it does not write a “carriage return line feed” character any more. This can be helpful if you wanted to write a single line to the text file from multiple PL/SQL statements. You can even manually go to the next line using “utl_file.new_line.”
All the examples in this article have been tested only with Oracle 10g version 2 on Windows Server 2003 standard edition. The examples would be a bit different in non-Windows environments. I request that you refer to your DBA or manuals covering the specific platform on which you are going to work.
I am confident enough that all of the examples should give no problem when worked with Oracle version 7.3 or above (on Windows). You can drop (or post) me a line if you do experience an issue. The examples can be directly copied, pasted and tested in your favorite PL/SQL environment. They should work without any change.
In my upcoming article I may also introduce you to some of the professional ways to deal with the same issues. Don’t forget to keep an eye on this website for the next article (or simply sign up for a newsletter). Any comments, suggestions, feedback, bugs, errors, enhancements are highly appreciated at email@example.com