reading files from PL/SQL in a loop
135084Dec 10 2003 — edited Dec 11 2003Hello,
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