Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: File I/O from Oracle 7.3 PL SQL

Re: File I/O from Oracle 7.3 PL SQL

From: Grace Frederick <grace_at_vantageone.com>
Date: 1997/10/02
Message-ID: <610n1h$t5g@akron5.neo.lrun.com>#1/1

I had this question also, and was pleased to run across this snippit. I created a procedure from it, but when I execute it, I get an 'invalid path' exception. I'm sure that the file is there.

I've read that the permissions on the file have to be set in a certain way in order to have access to the file. The file I'm trying to read is in $ORACLE_HOME and is owned by the same user as the one that started the Oracle server.

Can anyone give me an idea on what to try next?

Thanks in advance!

Ben Harmon wrote in message <609gcs$10e_at_news9.noc.netcom.net>...
>In article <3427F5AB.BFAE29B2_at_commserv.ucsb.edu>, Richard Allard
 <rallard_at_commserv.ucsb.edu> wrote:
>>I am relatively new to PL SQL, so please forgive a very basic question.
>>
>>I am trying to write a file from an Oracle 7.3 PL SQL script on the
>>server. I see in the documentation that the "UTL_FILE" package looks
>>like it will do this, but the documentation does not give any examples.
>>The documentation shows the function definition, but not the call (or
>>maybe the definition and the call are one in the same?).
>>
>>Can someone post a simple code snigglet with a simple select and the
>>file I/O statements?
>>
>>TIA
>>
>
>
>PROCEDURE read_file ( file_name VARCHAR2) IS
>
> /* Handle to file */
> file_handle UTL_FILE.FILE_TYPE;
>
> /* to hold lines from the file */
> line VARCHAR2(250);
>
>
> BEGIN
>
> /* Open file in 'read' mode. Note that the directory
 must
> || be listed in the init.ora file using
> || the 'utl_file_dir' parameter.
> */
> file_handle :=
> UTL_FILE.FOPEN('/mydirectory1/filelocation', file_name,
 'R');
>
> LOOP
> /* Get the next line */
> UTL_FILE.GET_LINE(file_handle, line);
>
> /* Do something */
> something(line);
>
> END LOOP;
>
> EXCEPTION
> WHEN NO_DATA_FOUND THEN
> UTL_FILE.FCLOSE (file_handle);
>
> WHEN UTL_FILE.INVALID_PATH THEN
> RAISE_APPLICATION_ERROR(-20000,
>'UTL_FILE:Invalid Path');
>
>END read_file;
>
>________________________________________________
>Ben Harmon
>benh_at_dascom.nospam.com
>**Please remove .nospam if you want to mail me**
>________________________________________________
Received on Thu Oct 02 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US