I'm trying to use the utl_file.fopen command (in this case to write a new file out, using SQL Developer v188.8.131.52.78 with Oracle and PL/SQL v184.108.40.206.0, and I just can't seem to shake the ORA-29823 - "invalid file operation" error.
It seems pretty clear it is a permissions issue, but I simply can't track it down. I've made sure to do the following:
> Establish the required directory in All_Directories table.
> Ensured the Oracle user has Write permissions on that folder in All_tab_Privs (It seems to default to include Read/Write/Execute).
> Ensure that I've used the specified directory name in the utl_file.fopen command.
> Ensured the folder exists in the server OS
> Ensured that the Oracle user account (in Windows) has full privileges on the subject folder. (When logged in as that user, I can create/edit/delete files at will.)
If I understand correctly, I shouldn't expect to need to modify init.ora with the versions I have, but maybe that's the missing piece? If adjustments are not necessary in init.ora, then I just don't know where else to look to make this command work.
Excerpts from the code are as follows:
I manually ran this to create the directory entry:
CREATE OR REPLACE DIRECTORY POLY_FILES AS 'C:\Approved_Locations\polygons';
Then, in the code attempting to write out there exists:
filPoly := utl_file.fopen('POLY_FILES', strFileName, 'w');
Where strFileName is just the name of the file, which I know is valid because I output this value to the Dbms Output right before this line.
thanks for any advice/insight.
A common cause of this is how the database is running under Windows.
If you go into Services on Windows, check the "Logon as" property. Often that is not the user you might expect it to be (it be local system or a service account depending on version).
You need to ensure that *this* account has access on the OS directory.
Another option to test is go very very simple, eg
- create a directory (say) C:\TEMP
- At the OS level give Full access to "Everyone"
- Then test *that* directory with UTL_FILE in simplest form
filPoly := utl_file.fopen('MY_DEMO_DIR', 'test.dat', 'w');
If that doesn't work, its time to call Support. But assuming it does, you work from there to establish where things are failing on your true directory.