suppose we have created new directory on database server and give it required privileges like :
[code]CREATE OR REPLACE DIRECTORY TEST_DIR AS ‘/usr/tmp’;
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO MYUSER;[/code]
Now i want to know if oracle has capable to read and write into this directory or not ?
thanks in advance.
You can use the
UTL_FILE
package. For example, this will verify that you can create a new file namedyour_test_file_name.txt
in the directory and write data to it[code]
DECLARE
l_file utl_file.file_type;
BEGIN
l_file := utl_file.fopen (‘UR_DIR’, ‘some_new_file_name.txt’, ‘W’);
utl_file.put_line (l_file, ‘Content of the file’);
utl_file.fclose (l_file);
EXCEPTION
WHEN utl_file.invalid_path THEN
dbms_output.put_line (‘File location is invalid’);
END;
[/code]
Also you can use
UTL_FILE.FGETATTR
to check if your file is exist and readable or not for more info about UTL_FILE click here.If you are looking for How to grant read and write on directory in oracle you can check my answer here
Regards.
It helps me a lot….Thanks,Gorakh
Check the below query :
SELECT * FROM all_tab_privs WHERE table_name = ‘your_directory’;