By the following code I am checking an existance of a file in the database operating system:
DROP DIRECTORY mydir;
DEFINE my_os_directory='/tmp';
CREATE OR REPLACE DIRECTORY mydir AS '&&my_os_directory';
DECLARE
ex BOOLEAN := TRUE;
blksz NUMBER := 0;
fl NUMBER := 0;
BEGIN
-- check if file exists
UTL_FILE.fgetattr ('MYDIR'
,'1.sql'
,ex
,fl
,blksz);
-- if directory does not exists - abort
IF (ex <> TRUE)
THEN
raise_application_error (-20031, 'file 1.sql does not exists in &&my_os_directory');
END IF;
END;
/
It is working fine
At the same way I am trying to check an existance of a directory:
DROP DIRECTORY mydir;
DEFINE my_os_directory='/tmp';
CREATE OR REPLACE DIRECTORY mydir AS '&&my_os_directory';
DECLARE
ex BOOLEAN := TRUE;
blksz NUMBER := 0;
fl NUMBER := 0;
BEGIN
-- check if directory exists
UTL_FILE.fgetattr ('MYDIR'
,'.'
,ex
,fl
,blksz);
-- if directory does not exists - abort
IF (ex <> TRUE)
THEN
raise_application_error (-20031, 'Directory &&my_os_directory does not exists');
END IF;
END;
/
It is not working
any idea ?