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!

reading files from PL/SQL in a loop

135084Dec 10 2003 — edited Dec 11 2003
Hello,

I have access to a unix directory where text files are stored? I have a small pl/sql routine which reads file one by one ie by passing file name as a parameters and then it process the file. My question is that, is there a way in pl/sql to read all files as they arrive in the unix directory and then process one by one.

My code logic is as follows
procedure load (p_inp_file varchar2(100))
is
fHandle UTL_FILE.FILE_TYPE;
v_string varchar2(4000);

begin
fHandle := UTL_FILE.FOPEN(vfile_dir_staging,p_inp_file,'r');--
loop
UTL_FILE.get_line (fHandle, v_string);
-- perform extraxt and load to a table
end loop;
end;
/

In this simple routine, I just read file one by one and process it one at a time. I need to write a procedure which reads all file ( read *.csv) and store in some array and then by looping UTL_FILE.FOPEN , process all the files.

I will appreciate your help. I have Oracle 9i Rel 1 and also cannot use DBMS_java package. I have to use Pl/SQL .

Thanks for all your help.

Suhail

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 8 2004
Added on Dec 10 2003
7 comments
1,896 views