You (or your DBA) must add a 'utl_file_dir' parameter to your init.ora
parameter file to inform the Oracle instance that it is legal for an
application program to do file I/O. [This is necessary for security
because an output file is written in the context of the user owning the
Oracle instance.]
In your case, add to init.ora:
utl_file_dir = /home/grads/shettiga/ins
Note: in practice, you may need a more generic file path than this,
unless this is your own personal database instance.
The path must be readable and/or writable by the instance owner and
accessible from the Oracle server. Restart the database instance and
you're in business.
John Gasch
Praveen Shettigar wrote:
>
> Hello,
>
> I am trying to write a PL/SQL program that will read the input data
> from a file and insert tuples into tables.
>
>
> My code :--
>
> set serveroutput on
> clear buffer;
>
> DECLARE
> --I/O Variables
> in_file_handle utl_file.file_type;
> out_file_handle utl_file.file_type;
> file_path varchar2(80) := '/home/grads/shettiga/ins';
> in_file_name varchar2(40) := 'insert.txt';
> out_file_name varchar2(40) := 'output.txt';
>
> BEGIN
>
> dbms_output.enable(30000);
> dbms_output.put_line('begin the program now:');
> dbms_output.new_line;
>
> in_file_handle := utl_file.fopen(file_path, in_file_name, 'r');
>
> dbms_output.put_line ('Now the input file has been opened');
>
> out_file_handle := utl_file.fopen(file_path, out_file_name, 'a');
> dbms_output.put_line ('Output file has been opened');
>
>
>
> EXCEPTION
> WHEN no_data_found THEN
> dbms_output.put_line('END OF FILE REACHED');
>
> WHEN utl_file.invalid_path THEN
> dbms_output.put_line('INVALID PATH');
>
> WHEN OTHERS THEN
> begin
> ROLLBACK;
> dbms_output.put_line('Something Wrong. TERMINATING....');
> end;
>
> END;
> /
>
> After running the program
> the output -
>
> begin the program now:
> INVALID PATH
>
> I checked the file name and the file location and i found that they
> represent a legal filename on the system, and the directory is also
> accessible.
> Then why i am getting such an error??
>
> thankyou
> Praveen
Received on Fri Mar 31 2000 - 20:51:26 CST