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!

utl_file.fopen

268349Sep 19 2006 — edited Sep 19 2006
Read all those postings about problems with using utl_file.fopen, so I'm rather informed.

But I have one further question: I'm working lokaly on Windows machine against a server database on a remote machine. I am trying to test out scripts stored on a local harddisk d:\test. Trying to read files from d:\test is not possible because of

ORA-20052: Invalid File Location
ORA-06512: error at line xx

-------------------------------------------------------------------------
So, what do i have to do, to test locally on d:\test against a remote database?

1* select * from v$parameter where name like '%utl%'
NUM NAME TYPE VALUE ISDEFAULT ISSES ISSYS_MOD ISMODIFIED ISADJ DESCRIPTION
---------- --------------- ---------- ---------- --------- ----- --------- ---------- ----- -------------------------------
528 utl_file_dir 2 TRUE FALSE FALSE FALSE FALSE utl_file accessible directories


source:
set serveroutput on size 100000
declare
vSFile utl_file.file_type;
vNewLine VARCHAR2(200);
BEGIN
vSFile := utl_file.fopen('D:\test', 'test.txt','r');

IF utl_file.is_open(vSFile) THEN
LOOP
BEGIN
utl_file.get_line(vSFile, vNewLine);

IF vNewLine IS NULL THEN
EXIT;
END IF;

END;
END LOOP;
COMMIT;
END IF;
utl_file.fclose(vSFile);
EXCEPTION
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
WHEN utl_file.invalid_filehandle THEN
RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
WHEN utl_file.invalid_operation THEN
RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
WHEN utl_file.read_error THEN
RAISE_APPLICATION_ERROR (-20055, 'Read Error');
WHEN utl_file.internal_error THEN
RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
WHEN utl_file.charsetmismatch THEN
RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR But Later I/O Inconsistent');
WHEN utl_file.file_open THEN
RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
WHEN utl_file.invalid_maxlinesize THEN
RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
WHEN utl_file.invalid_filename THEN
RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
WHEN utl_file.access_denied THEN
RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
WHEN utl_file.invalid_offset THEN
RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
WHEN others THEN
RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
END read_demo;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 17 2006
Added on Sep 19 2006
5 comments
641 views