ORA-29283: invalid file operation when calling utl_file.fopen on Windows server 2016 - windows

Most of the answers I've seen are for Linux. Windows permissions have an element of black magic about them. This is Windows Server 2016.
I created the d:\data\transfer\sirius\ directory on the Oracle database server.
As SYSDBA I do the following:
create or replace directory SIRIUS_DIR as 'd:\data\transfer\sirius\';
grant read,write on directory SIRIUS_DIR to SIRIUS;
Then on another server, in a SQL*Plus session as the SIRIUS user, I run:
DECLARE myFile utl_file.file_type;
BEGIN
myFile := utl_file.fopen('SIRIUS_DIR ', 'random.txt', 'w', 32000);
END;
/
Which gives:
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 41
ORA-06512: at "SYS.UTL_FILE", line 478
ORA-06512: at line 3
How to proceed?

Figured it out. You need to grant full access to the ORA_INSTALL group to the directory in question on the database. According to the Oracle configuration docs:
The ORA_INSTALL group contains all the Oracle Home Users for all
Oracle homes on the server.
Thanks to this kindly blogger for his solution.

Related

ORA-06512: in "SYS.UTL_FILE", line 536

Guys i have a problem with this error at ORACLE i think is permissions but i don't know where can i do something.
HELP!
ORA-20123: ERROR DMM_INTER_STOCK_SAP: ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: in "DMM.GEN_PKG_INTER" line 973
ORA-06512: online 2
The process has finished.
DIRECTORY_NAME DIR_DEP_DMM_BK
DIRECTORY_PATH /oracle/app/oracle/file/DEP/DMM/BK
Privilege list EXECUTE, READ, WRITE
ORA-06512: at "SYS.UTL_FILE", line 536
means you got the error during an FOPEN call. You need to ensure that the OS and the database are "in alignment" in terms of permissions.
The database privs you have listed indicate you can read/write the directory object. But you also need to check the OS directory /oracle/app/oracle/file/DEP/DMM/BK that it (a) exists, and (b) can be written to by the database OS account (typically 'oracle').

Oracle DATAPUMP import failed

I am currently trying to import a database using DBMS_DATAPUMP in PL/SQL using the following script.
DECLARE
h1 NUMBER;
BEGIN
h1 := DBMS_DATAPUMP.OPEN('IMPORT', 'FULL', NULL, DBMS_SCHEDULER.generate_job_name, 'LATEST');
DBMS_DATAPUMP.ADD_FILE(handle => h1, filename => 'EXAMPLE6.DMP', directory => 'DUMP');
DBMS_DATAPUMP.START_JOB(h1);
dbms_datapump.detach(h1);
END;
/
Everytime I execute this code, I get the following error message.
ERROR in line 1:
ORA-39001: invalid argument value
ORA-06512: in "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: in "SYS.DBMS_DATAPUMP", line 4929
ORA-06512: in "SYS.DBMS_DATAPUMP", line 5180
ORA-06512: in line 5
I already googled the error, but the answer mostly consisted of checking if the directory was already created and if the user had read and write access to the directory.
I also tried the impdp tool just as an experiment, to see if I could execute imports that way.
impdp pdb2 directory="DUMP" dumpfile="EXAMPLE6.DMP"
Based on the user I am executing impdp as, I get different error messages.
As a user with all privileges granted:
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39155: error expanding dump file name "C:\Users\...\EXAMPLE6.DMP"
ORA-48128: opening of a symbolic link is disallowed
As the sysdba user:
ORA-39002: invalid operation
ORA-39070: unable to open the log file
ORA-39087: directory name DUMP is invalid
As I already said, the directory does exist on my drive, I created the directory called DUMP in Oracle and granted read and write access to my user.
All help would be appreciated and I would be happy to clarify if I wrote something confusing!
Edit:
Output of select directory_name, directory_path from dba_directories;
DIRECTORY_NAME
--------------------------------------------------------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
DUMP
C:\Users\Nemanja\Desktop\oraclePLS
I forgot to mention, that the Oracle service has complete access to the specified Windows directory.

Cannot write file xml output form a procedure - ORA-06512: a "SYS.UTL_FILE"

in our production environment we use a procedure that read from our DB Oracle 12c and write about 2000 files xml in output on the filesystem, all in the same directory.
Now we have a problem: after that 1400 files are already writed, the procedure fails with error:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
There is enough space on the filesystem to write the files and i have already checked the permissions.
In the procedure we call:
xdb.dbms_xslprocessor.clob2file(xml_document,R_FILE_FOLDER,substr(xml_file_name,0,instr(xml_file_name,'.',-1)-1)||'.unc',nls_charset_id('AL32UTF8'));
Thank you

Open a remote file using utl_file.fopen on Windows

I have to access a remote file in a different computer using utl_file.
This is what I did:
create a user with Adminstrator+Users+ora_db profile in the remote PC, the same user is created with the same role in my PC.
Run the Oracle Services using this administrator account
Map the remote directory under Windows
use the following command to configure and accesss the file:
create or replace directory REMOTE_LOG as '\\remote_shared_dir\log';
declare
f UTL_FILE.FILE_TYPE;
line VARCHAR2(32767) ;
begin
BEGIN
f := UTL_FILE.FOPEN('REMOTE_LOG','toto.txt','R',32764);
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('err '||sqlerrm);
END;
UTL_FILE.GET_LINE( f, line );
UTL_FILE.FCLOSE( f ) ;
end;
But it failed with:
[Error] Execution (7: 3): ORA-29282: invalid file ID
ORA-06512: at "SYS.UTL_FILE", line 735
ORA-06512: at line 13
When I remove the exception handler I instead see:
[Error] Execution (7: 3): ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 8
What am I doing wrong?

Invalid file operation in pl/sql

I was learning PL/SQL and I have been getting this error as "invalid file operation since long"
The code is as follows:
SET SERVEROUTPUT on;
CREATE or replace directory DESKTOP as 'C:\Users\Gadre\Desktop';
declare
v1 varchar2(32767);
f1 utl_file.file_type;
begin
f1 :=utl_file.fopen('DESKTOP','test.docx','r');
dbms_output.put_line('HELLO WORLD');
end;
The error is:
Error report:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 5
29283. 00000 - "invalid file operation"
*Cause: An attempt was made to read from a file or directory that does
not exist, or file or directory access was denied by the
operating system.
*Action: Verify file and directory access privileges on the file system,
and if reading, verify that the file exists.
The file does exist surely. Plus I am through admin access so I think I do have privileges.

Resources