File dump procedure : Utility Procedure « Stored Procedure Function « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
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 Tutorial
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 » Stored Procedure Function » Utility Procedure 
File dump procedure
 
SQL>
SQL> create or replace procedure file_dumpp_directory in varchar2,p_filename  in varchar2 )
  2  as
  3      type array is table of varchar2(5index by binary_integer;
  4
  5      l_chars  array;
  6      l_bfile  bfile;
  7      l_buffsize number default 15;
  8      l_data   varchar2(30);
  9      l_len    number;
 10      l_offset number default 1;
 11      l_char   char(1);
 12  begin
 13      l_chars(0)  := '\0';
 14      l_chars(13:= '\r';
 15      l_chars(10:= '\n';
 16      l_chars(9)  := '\t';
 17
 18      l_bfile := bfilenamep_directory, p_filename );
 19      dbms_lob.fileopenl_bfile );
 20
 21      l_len := dbms_lob.getlengthl_bfile );
 22      whilel_offset < l_len )
 23      loop
 24          l_data := utl_raw.cast_to_varchar2(dbms_lob.substrl_bfile, l_buffsize, l_offset ));
 25
 26          for i in .. length(l_data)
 27          loop
 28              l_char := substr(l_data,i,1);
 29
 30              if asciil_char between 32 and 126
 31              then
 32                  dbms_output.putlpad(l_char,3) );
 33              elsif l_chars.existsascii(l_char) ) )
 34              then
 35                  dbms_output.putlpadl_chars(ascii(l_char))) );
 36              else
 37                  dbms_output.putto_char(ascii(l_char),'0X') );
 38              end if;
 39          end loop;
 40          dbms_output.new_line;
 41
 42          l_offset := l_offset + l_buffsize;
 43      end loop;
 44      dbms_lob.closel_bfile );
 45  end;
 46  /

Procedure created.

SQL>
SQL>
SQL> exec file_dump'MY_FILES', 'demo17.dat' );
BEGIN file_dump'MY_FILES', 'demo17.dat' )END;

*
ERROR at line 1:
ORA-22285: non-existent directory or file for
FILEOPEN operation
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at "JAVA2S.FILE_DUMP", line 19
ORA-06512: at line 1


SQL>
SQL> --

 
Related examples in the same category
1. Assert procedure
2. Use stored procedure to output table content
3. emp table lookup
4. Use stored procedure to log message
5. Create a stored procedure to measure a table usage
6. Procedure does not count space
7. Copy tables
8. Count credits
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.