Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

utl_file.fopen error 2

Status
Not open for further replies.

DK2004

Programmer
Jun 5, 2004
2
US
Hello,

I am running Oracle SQL *Plus on Windows system and trying to open a test file. I would greatly appreciate for your kind help.

CREATE OR REPLACE PROCEDURE File_open
IS
output utl_file.file_type;
begin
output := utl_file.fopen( 'c:\temp\', 'File_open.txt', 'w',32000 );
utl_file.fclose( output );
end;
/

If I run this on SQL *Plus prompt, it gives following error. I checked c:\temp exist in the system.
------------------------------------------------------
SQL> exec File_open
BEGIN File_open; END;

*
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 120
ORA-06512: at "SYS.UTL_FILE", line 293
ORA-06512: at "SYSTEM.FILE_OPEN", line 5
ORA-06512: at line 1

------------------------------------------------------

Best Regards,
DK
 
Sorry, in may last request, I didn't mention. I tried some more things. I am using Oracle 9i. Could you pl help me to fix the problem. Thanks in advance for your help.
--------------------------------------------------
create directory file_dir as 'c:\temp'
GRANT write on directory file_dir to public

--------------------------------------------------
CREATE OR REPLACE PROCEDURE File_open
IS
output utl_file.file_type;
begin
output := utl_file.fopen( 'file_dir', 'File_open.txt', 'w',32000 );
utl_file.fclose( output );
end;
/

------------------------------------------------------
SQL> exec file_open
BEGIN file_open; END;

*
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 120
ORA-06512: at "SYS.UTL_FILE", line 293
ORA-06512: at "SYSTEM.FILE_OPEN", line 5
ORA-06512: at line 1

 
DK,

Although I suspect that your commands (create directory file_dir as 'c:\temp'; GRANT write on directory file_dir to public;) should have taken care of allowing writes to c:\temp, let's eliminate one possible error situation by setting your init.ora parameter, utl_file_dir = *, then please try your code again. If that does not resolve your problem, then we can dig deeper.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 02:44 (06Jun04) UTC (aka "GMT" and "Zulu"), 19:44 (05Jun04) Mountain Time)

 
DK, you should read about utl_file more: each procedure in this package may raise a number of predefined exceptions defined within package spec. You should catch and process them.
BTW do you mean c:\temp\ of the same box where Oracle runs?


Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top