0
votes

I have following privileges CREATE ANY DIRECTORY, read, write on directory DOCS to user_name

I am using oracle 10g on Windows.

I have first created the directory as

CREATE DIRECTORY DOCS AS 'C:\Documents and Settings\Owner\Desktop\file';

Directory created successfully.

Now when I tried to execute following code

DECLARE
 l_file         UTL_FILE.file_type;
 l_location     VARCHAR2(100) := 'DOCS';
 l_filename     VARCHAR2(100) := 'test.pdf';
 l_text         VARCHAR2(32767);
BEGIN
-- Open file.
 l_file := UTL_FILE.fopen(l_location, l_filename, 'r', 32767);
-- Read and output first line.
 UTL_FILE.get_line(l_file, l_text, 32767);
 dbms_output.put_line('First Line: |' || l_text || '|');
-- Close the file.
 UTL_FILE.fclose(l_file);
END;

I get these errors

ORA-29283: invalid file operation

ORA-06512: at "SYS.UTL_FILE", line 475

ORA-29283: invalid file operation

ORA-06512: at line 8

1
do you have access to the directory? check the utl_file_dir database parameter - davegreen100
You have a directory on your desktop named 'file'? Does the Oracle account have access to your home directory? - Alex Poole
I have checked the directory exists by select * from dicrectories. @AlexPoole - Muhammad Hannan
I'm talking about the operating system directory and operating system account's ability to see it; not the Oracle Directory object. They have to tie up, but Oracle has to be able to access the operating system directory too. - Alex Poole
Oracle is its own user (or at least it is in Unix. I don't know precisely how it works in Windows), and you're trying to write into a folder owned by a different user. Create a folder called C:\files\ or something and point your DOCS directory to that. - Steven Eccles

1 Answers

0
votes

i don't have access to oracle on windows, but something like this in you init.ora file

UTL_FILE_DIR=c:\DOCS

you will then need to restart oracle

you should also be able to do the following (but i've not tested it)

alter system set utl_file_dir=c:\DOCS scope=both