| File and operating system interaction with SQL and PLSQL | |||||
SUMMARY: FIELD | TYPE | METHOD | DETAIL: FIELD | TYPE | METHOD |
Method Summary | |
file_type | get_file(p_file_path varchar2)
gets a simple file handle. |
file_type | get_file(p_directory varchar2, p_filename varchar2)
gets a simple file handle by directory object and file name. |
file_type | get_file(p_bfile bfile)
gets a simple file handle by BFILE. |
file_list_type | get_file_list(p_directory file_type)
gets all file handles in a directory (directory listing) as a virtual table. |
file_list_type | get_file_list(p_directory_name varchar2)
gets all file handles in a directory (directory listing) as a virtual table. |
file_list_type | get_file_list_p(p_directory file_type)
gets all file handles in a directory (directory listing) as a virtual table. |
file_list_type | get_file_list_p(p_directory_name varchar2)
gets all file handles in a directory (directory listing) as a virtual table. |
varchar2 | get_fs_encoding()
gets the current file system encoding |
varchar2 | get_path_separator()
returns the operating system-specific path separator character; "/" on Unix, "\" on Windows. |
file_list_type | get_recursive_file_list(p_directory file_type)
gets all file handles in a directory and recursively in all subdirectories (directory listing) as a virtual table. |
file_list_type | get_recursive_file_list_p(p_directory file_type)
gets all file handles in a directory and recursively in all subdirectories (directory listing) as a virtual table. |
file_list_type | get_root_directories()
gets file handles for all root directories (one for each drive letter on windows platforms) as a virtual table. |
file_type | get_root_directory()
returns file handle for the root directory (the first drive letter on windows platforms). |
varchar2 | remove_multiple_separators(p_path varchar2)
This function "normalizes" a file path by removing trailing slashes and multiple slashes within the path. |
| set_fs_encoding(p_fs_encoding varchar2, p_reset_session boolean)
sets the encoding to use for file names. |
Method Detail |
public file_type get_file(p_file_path varchar2)
SQL> select file_pkg.get_file('/home/oracle/nonexisting_file.txt') file_handle from duaL; FILE_HANDLE ---------------------------------------------------------------------------------------------- FILE_TYPE('/home/oracle/nonexisting_file.txt', NULL, NULL, NULL, NULL, NULL, NULL, 'N') SQL> select file_pkg.get_file('/home/oracle/existing_file.txt') file_handle from dual; FILE_EXISTS --------------------------------------------------------------------------------------------------- FILE_TYPE('/home/oracle/existing_file.txt', 'existing_file.txt', 0, '03.02.10', 'N', 'Y', 'Y', 'Y')
p_file_path
-
the absolute path to the filepublic file_list_type get_file_list(p_directory file_type)
select * from table(file_pkg.get_file_list(file_pkg.get_file('/')))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_file_list(file_pkg.get_file('/'))) e
p_directory
-
Directory from which the file handles to be obtainedpublic file_list_type get_recursive_file_list(p_directory file_type)
select * from table(file_pkg.get_file_list(file_pkg.get_file('/')))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_recursive_file_list(file_pkg.get_file('/'))) e
p_directory
-
Directory from which the file handles to be obtainedpublic varchar2 get_path_separator()
public file_list_type get_root_directories()
public file_type get_root_directory()
SQL> select file_pkg.get_root_directory() ROOT from dual; ROOT -------------------------------------------------------------------------------- FILE_TYPE('/', '', 4096, '22.01.10', 'Y', 'N', 'Y', 'Y')
public file_list_type get_recursive_file_list_p(p_directory file_type)
select * from table(file_pkg.get_file_list(file_pkg.get_file('/')))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_recursive_file_list(file_pkg.get_file('/'))) e
p_directory
-
Directory from which the file handles to be obtainedpublic file_list_type get_file_list_p(p_directory file_type)
select * from table(file_pkg.get_file_list(file_pkg.get_file('/')))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_file_list(file_pkg.get_file('/'))) e
p_directory
-
Directory from which the file handles to be obtainedpublic set_fs_encoding(p_fs_encoding varchar2,
p_reset_session boolean)
file_pkg.set_fs_encoding('windows-1252');On a 10g database this call must be executed before the very first file system access.
p_fs_encoding
-
The encoding to use for filesystem access; e.g. windows-1252, iso-8859-1, utf-8p_reset_session
-
11g and higher: Reset java session before (default is true).public varchar2 get_fs_encoding()
public file_type get_file(p_directory varchar2,
p_filename varchar2)
SQL> select file_pkg.get_file('HOMEDIR', 'existing_file.txt') file_handle from dual; FILE_HANDLE --------------------------------------------------------------------------------------------------- FILE_TYPE('/home/oracle/existing_file.txt', 'existing_file.txt', 0, '03.02.10', 'N', 'Y', 'Y', 'Y')
p_directory
-
the name of the directory objectp_filename
-
the file namepublic file_type get_file(p_bfile bfile)
SQL> select file_pkg.get_file(bfilename('HOMEDIR', 'existing_file.txt')) file_handle from dual; FILE_HANDLE --------------------------------------------------------------------------------------------------- FILE_TYPE('/home/oracle/existing_file.txt', 'existing_file.txt', 0, '03.02.10', 'N', 'Y', 'Y', 'Y')
p_bfile
-
the bfile objectpublic file_list_type get_file_list(p_directory_name varchar2)
select * from table(file_pkg.get_file_list('HOMEDIR'))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_file_list('HOMEDIR')) e
p_directory_name
-
name of an existing directory object to be listedpublic file_list_type get_file_list_p(p_directory_name varchar2)
select * from table(file_pkg.get_file_list('HOMEDIR'))This function allows operations on multiple files within a single SQL SELECT command. The following SQL gets the content of all files in a directory as a BLOB:
select value(e).get_content_as_blob() from table(file_pkg.get_file_list('HOMEDIR')) e
p_directory_name
-
name of an existing directory object to be listedpublic varchar2 remove_multiple_separators(p_path varchar2)
select file_pkg.remove_multiple_separators('/path//to///a/file/') as NORMALIZED_PATH from dual; NORMALIZED_PATH ------------------------- /pah/to/a/file
p_path
-
filesystem path to normalize
| File and operating system interaction with SQL and PLSQL | |||||
SUMMARY: FIELD | TYPE | METHOD | DETAIL: FIELD | TYPE | METHOD |