HomeOracle Page 4 - Reading Text Files using Oracle PL/SQL and UTL_FILE
Improving it a bit with exception handling - Oracle
In this series of articles, we shall concentrate on working with file input/output using Oracle PL/SQL packages. Even though I start with simple examples in the first article of this series, I shall introduce you (in my upcoming articles) to the power of the most advanced techniques using file input/output with Oracle PL/SQL.
In the previous sections, we worked by reading a single line from the text file. Let us consider the following situations:
The file you are trying to access doesn't exist.
The file you are trying to access got corrupted.
You don't have the permission to access the file.
No lines present in that file.
Too many chars (say more than 200) present on the first line itself.
And so on. How do we solve such problems? Even though we will not be able to address every possible error, there exist some pre-defined exceptions to handle some of the scenarios. Following are the pre-defined exceptions most frequently used when working with UTL_FILE package:
My upcoming article will address further issues like "working with a larger number of lines", "better exception handling", "writing to files" and so on. I may also introduce you to some of the professional ways to deal 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