Hi,
we are migrating from an Oracle 12 DB to the 19c version. I have some procedures that write data to files on the DB server via utl_file.fopen. I have created the directory to write to before via CREATE DIRECTORY.
Here is the example code
DECLARE
f_output utl_file.file_type;
BEGIN
f_output := UTL_FILE.fopen('TMP', 'test.csv', 'W');
UTL_FILE.put_line(f_output,'TestLine');
UTL_FILE.fflush(file => f_output);
UTL_FILE.FCLOSE(f_output);
END;
Runing this code works fine, file is created, content written, file closed.
BUT if i create a procedure with exact the same code and run this procedure, with the same user on the same server in the same session as the code aboveā¦
CREATE OR REPLACE PROCEDURE test_out IS
f_output utl_file.file_type;
BEGIN
f_output := UTL_FILE.fopen('TMP', 'test.csv', 'W');
UTL_FILE.put_line(f_output,'TestLine');
UTL_FILE.fflush(file => f_output);
UTL_FILE.FCLOSE(f_output);
END;
/
exec test_out;
then this does NOT work but throws this ORA error
ORA-29280: invalid directory object
ORA-06512: at "SYS.UTL_FILE", line 41
ORA-06512: at "SYS.UTL_FILE", line 478
ORA-06512: at "PFK.TEST_OUT", line 5
ORA-06512: at line 2
Does anyone have an idea why the code does not work within a procedure? All other parameters are the same, DB / Server / User / Permissions
Greetings, sun