Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is UTL_FILE.FOPEN failing?

6,379 views
Skip to first unread message

PeteOlcott

unread,
Apr 12, 2012, 11:16:21 AM4/12/12
to
INPUT:
create or replace directory filesdir as 'c:\';
grant read on directory filesdir to public;

declare
namesfile UTL_FILE.FILE_TYPE;
begin
-- Syntax : FOPEN ( directory alias, filename, open mode)
namesfile := UTL_FILE.FOPEN('FILESDIR','CASELIST.TXT','r');
end;

OUTPUT:

SQL> create or replace directory filesdir as 'c:\';

Directory created.

SQL> grant read on directory filesdir to public;

Grant succeeded.

SQL>
1 declare
2 namesfile UTL_FILE.FILE_TYPE;
3 begin
4 -- Syntax : FOPEN ( directory alias, filename, open mode)
5 namesfile := UTL_FILE.FOPEN('FILESDIR','CASELIST.TXT','r');
6* end;
7 /
declare
*
ERROR at line 1:
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 488
ORA-29283: invalid file operation
ORA-06512: at line 5

ddf

unread,
Apr 13, 2012, 2:10:13 PM4/13/12
to
I'll ask the obvious question: Does c:\CASELIST.TXT exist? I doubt
that it does:

SQL> $ls c:\caselist.txt
ls: c:\caselist.txt: No such file or directory

SQL>
SQL> declare
2 namesfile UTL_FILE.FILE_TYPE;
3 begin
4 -- Syntax : FOPEN ( directory alias, filename, open
mode)
5 namesfile := UTL_FILE.FOPEN('FILESDIR','CASELIST.TXT','r');
6 end;
7 /
declare
*
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 line 5


SQL>
SQL> $touch c:\caselist.txt

SQL>
SQL> declare
2 namesfile UTL_FILE.FILE_TYPE;
3 begin
4 -- Syntax : FOPEN ( directory alias, filename, open
mode)
5 namesfile := UTL_FILE.FOPEN('FILESDIR','CASELIST.TXT','r');
6 end;
7 /

PL/SQL procedure successfully completed.

SQL>


David Fitzjarrell

PeteOlcott

unread,
Apr 16, 2012, 7:37:28 AM4/16/12
to
> David Fitzjarrell- Hide quoted text -
>
> - Show quoted text -

The unix command "$ls" does not work on unix, when in sqlplus.

SQL> $ls CASELIST.txt
SP2-0734: unknown command beginning "$ls CASELI..." - rest of line
ignored.

The oracle database is stored on a unix server.

Thomas Olszewicki

unread,
Apr 16, 2012, 9:27:18 AM4/16/12
to
> The oracle database is stored on a unix server.- Hide quoted text -
>
> - Show quoted text -

'c:\' is wrong path on unix server.
Hth
Thomas

ddf

unread,
Apr 16, 2012, 4:08:31 PM4/16/12
to
> The oracle database is stored on a unix server.- Hide quoted text -
>
> - Show quoted text -

Why are you then trying to use a DOS/Windows drive naming convention
on a UNIX server? As stated in an earlier response c:\ is not valid
on UNIX. Since c:\ is not a valid drive on UNIX and the directories
are referenced locally you cannot declare a directory on a Windows
server in an Oracle database running on UNIX/Linux. Oracle can't get
to that directory so the operation fails.

Use a local UNIX directory for your Oracle directory path. Or install
Oracle on windows.

David Fitzjarrell

Pól

unread,
Apr 25, 2012, 11:50:21 PM4/25/12
to


On 12/04/12 16:16, PeteOlcott wrote:


Go to forums.oracle.com and sign up = it's free and signal/noise is very
high.

Paul...

0 new messages