UTL_File related exception : UTL_FILE « System Packages « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » System Packages » UTL_FILE 
31. 38. 7. UTL_File related exception
SQL>
SQL> CREATE OR REPLACE PROCEDURE sp_utlfile
  2  IS
  3    v_filehandle UTL_FILE.FILE_TYPE;
  4    v_newline VARCHAR2(1023);
  5  BEGIN
  6    IF NOT UTL_FILE.IS_OPEN(v_filehandleTHEN
  7      v_filehandle := UTL_FILE.FOPEN('c:\temp', 'input_file.txt', 'r');
  8    END IF;
  9
 10    LOOP
 11      BEGIN
 12
 13        UTL_FILE.GET_LINE(v_filehandle, v_newline);
 14        DBMS_OUTPUT.PUT_LINE (v_newline);
 15      EXCEPTION
 16
 17        WHEN NO_DATA_FOUND THEN
 18          EXIT;
 19      END;
 20    END LOOP;
 21
 22    UTL_FILE.FCLOSE(v_filehandle);
 23
 24  EXCEPTION
 25    WHEN UTL_FILE.INVALID_PATH THEN
 26      UTL_FILE.FCLOSE_ALL;
 27      RAISE_APPLICATION_ERROR(-20051'Invalid Path');
 28
 29    WHEN UTL_FILE.INVALID_MODE THEN
 30      UTL_FILE.FCLOSE_ALL;
 31      RAISE_APPLICATION_ERROR(-20052'Invalid Mode');
 32
 33    WHEN UTL_FILE.INTERNAL_ERROR THEN
 34      UTL_FILE.FCLOSE_ALL;
 35      RAISE_APPLICATION_ERROR(-20053'Internal Error');
 36
 37    WHEN UTL_FILE.INVALID_OPERATION THEN
 38      UTL_FILE.FCLOSE_ALL;
 39      RAISE_APPLICATION_ERROR(-20054'Invalid Operation');
 40
 41    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
 42      UTL_FILE.FCLOSE_ALL;
 43      RAISE_APPLICATION_ERROR(-20055'Invalid Operation');
 44
 45    WHEN UTL_FILE.WRITE_ERROR THEN
 46      UTL_FILE.FCLOSE_ALL;
 47      RAISE_APPLICATION_ERROR(-20056'Invalid Operation');
 48  END;
 49  /

Warning: Procedure created with compilation errors.

SQL>
SQL> execute sp_utlfile ;
BEGIN sp_utlfile ; END;

      *
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object JAVA2S.SP_UTLFILE is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored


SQL>
31. 38. UTL_FILE
31. 38. 1. File open and close with UTL_FILE package
31. 38. 2. File open flags
31. 38. 3. Save table records to a file
31. 38. 4. Use UTL_FILE package to create a file
31. 38. 5. Open a file with mode passed in
31. 38. 6. utl_file.invalid_&&firstparm
31. 38. 7. UTL_File related exception
31. 38. 8. UTL_FILE.IS_OPEN
31. 38. 9. A PL/SQL block to read an operating system file called BLOB.JPG that contains 1 row of binary data.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.