Re: PL/SQL Help Needed.

From: Teo <t4ck_at_hotmail.com>
Date: 2000/05/23
Message-ID: <8genf6$4ac$1_at_pollux.matav.net>#1/1


K.M. Cheng <kcheng_at_worldonline.nl> wrote in message news:8gehfh$ccr$1_at_nereid.worldonline.nl...
> I was wondering if someone can tell me how i can read the content of a
 file
> with PL/SQL.
> Is there a function to read in a flat/text file?
>
> Thanks!
> KC.
>

CREATE OR REPLACE PROCEDURE ReadFile (File_Path VARCHAR2,File_Name VARCHAR2) AS
f_handle UTL_FILE.FILE_TYPE;
str VARCHAR2(100);
BEGIN
f_handle:=UTL_FILE.FOPEN(LTRIM(RTRIM(File_Path)),File_Name,'r'); WHILE TRUE LOOP
   UTL_FILE.GET_LINE(f_handle,str);

  • some code... END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN -- watch OUT, NO_DATA_FOUND IS raised WHEN EOF...
     UTL_FILE.FCLOSE(f_handle);
END;
/

and you can write to a file with UTL_FILE.PUT_LINE() ...

Note: you have to include the UTL_FILE_DIR = <path> parameter in your init.ora to specify the directories to perform file I/O. Received on Tue May 23 2000 - 00:00:00 CEST

Original text of this message