Oracle
  Home arrow Oracle arrow Page 4 - Reading Text Files using Oracle PL/SQL...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Reading Text Files using Oracle PL/SQL and UTL_FILE
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 63
    2006-04-11

    Table of Contents:
  • Reading Text Files using Oracle PL/SQL and UTL_FILE
  • How to read a text file from a file system and display the contents using PL/SQL
  • How to read a text file from a file system and display the contents using PL/SQL: discussion
  • Improving it a bit with exception handling

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Reading Text Files using Oracle PL/SQL and UTL_FILE - Improving it a bit with exception handling
    (Page 4 of 4 )

    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:

    INVALID_PATH
    INVALID_MODE
    INVALID_FILEHANDLE
    INVALID_OPERATION
    READ_ERROR
    WRITE_ERROR
    INTERNAL_ERROR
    NO_DATA_FOUND
    VALUE_ERROR
    INVALID_MAXLINESIZE

    For a complete list of exceptions, I suggest you go through the Oracle documentation for the respective version you are using.

    If you are new to exception handling, I suggest you read my contributions at

    http://www.devshed.com/c/a/Oracle/Database-Interaction-with-PLSQL-
    Predefined-Exceptions/

    http://www.devshed.com/c/a/Oracle/Database-Interaction-with-PLSQL-User-
    defined-Exceptions-Nested-Blocks/

    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 jag_chat@yahoo.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys. Starting a small series to work with text files using PL/SQL. Enjoy...
     

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway