Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

read&write server files from plsql code

Gor_MahiaOct 22 2021

All,
i am having the below anonymous block to READ and WRITE to a file located on the server location mapped to the directory object as below,
DIRECTORY_NAME : DIRECTORY_PATH
MY_DIR : \\QRD_ATT\Consumer_Projects\commonfiles\portal

grants exists as below,
GRANTEE TABLE_SCHEMA TABLE_NAME PRIVILEGE GRANTABLE
=========================================================
APTS SYS MY_DIR EXECUTE YES
APTS SYS MY_DIR READ YES
APTS SYS MY_DIR WRITE YES

I am running this code from APTS shema
DECLARE
F UTL_FILE.FILE_TYPE;
CURSOR C1 IS select EMPNO, ENAME, SAL from emp where rownum <= 10 ;
C1_R C1%ROWTYPE;
BEGIN
F := UTL_FILE.FOPEN('MY_DIR','txt1.txt','w',32767);
FOR C1_R IN C1
LOOP
UTL_FILE.PUT(F,C1_R.EMPNO);
UTL_FILE.PUT(F,','||C1_R.ENAME);
UTL_FILE.PUT(F,','||C1_R.SAL);
UTL_FILE.NEW_LINE(F);
END LOOP;
UTL_FILE.FCLOSE(F);
END;

but iam getting the below error yet I've full read & write access to the location ?
Error report -
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at line 6
29283. 00000 - "invalid file operation%s"
*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.

Any help why iam getting this error?

thanks.

Comments
Post Details
Added on Oct 22 2021
11 comments
996 views