Thursday, April 9, 2020

How to test read/write permissions on UTL directory (in UNIX) from database or backend


Below is the sample script which can be run from TOAD/SQL*PLUS to test the read write permissions on UTL directory from database or backend
DECLARE
  l_file utl_file.file_type;
BEGIN
  l_file := utl_file.fopen( 'DBA_UTL_DIR_NAME', 'test_file_name.txt', 'W' );
  utl_file.put_line( l_file, 'Here is sample text' );
  utl_file.fclose( l_file );
END;
  • Direcory name (DBA_UTL_DIR_NAME) should exists in DBA_DIRECTORIES table
  • Make sure that the UTL_FILE directory path exists in UNIX
select * from DBA_DIRECTORIES where directory_name = 'DBA_UTL_DIR_NAME'

Unix commands to get the count of files

 ls -l *.rdf | wc -l