I have an SQL file which contains 2 block of code, both using UTL_FILE functions to write 2 different files in same directory.
The issue I encounter is the first block of code executes successfully but when executing the second block of code I encounter ORA-29283: invalid file operation.
My code is as follows:
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
vline varchar2(4000);
BEGIN
fileHandler := UTL_FILE.FOPEN('STAGING_REPORT', 'Report_1.csv', 'W',4000);
UTL_FILE.FCLOSE(fileHandler);
end;
/
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
vline varchar2(4000);
BEGIN
fileHandler := UTL_FILE.FOPEN('STAGING_REPORT', 'Report_2.csv', 'W',4000);
UTL_FILE.FCLOSE(fileHandler);
end;
/
When I try to execute this on SQLDeveloper I firstly executed two block separately. In that scenario, thew first block executed successfully but the second block threw ORA-29283.
In second attempt, I tried to execute both block simultaneously i.e selecting both of them and hitting RUN. In this scenario too, my first block executes successfully but my second block doesn't.
After numerous such attempts, currently, both of the blocks throw the ORA_29283 error.
There are no report files(REPORT_1 and REPORT_2) already in the STAGING_REPORT. The UTL_FILE.FOPEN create them in runtime.
What seems peculiar is this code executed successfully just half-week before and suddenly it is behaving abnormally.
I am running on Oracle 12c. Is there anything specific I am missing here?
(I have already checked the permissions and other basic things like permission to directory and if directory exists , as I earlier mentioned this code was executing half a week before and it partially executed when I execute it manually )
I have also tried using two different handler names for both the block but no success came my way