create global temporary table BLUEUSER.dirlist(
filename varchar2(255),
filesize number,
filedate date)
on commit delete rows;
/

create or replace and compile java source named DirList as
import java.io.*;
import java.sql.*;
public class DirList
{
public static void getList(String directory) throws SQLException
{
File path=new File(directory);
String[] fileList=path.list();
String fileName;
long fileSize;
long fileDate;
for (int i=0;i<filelist .length; i++)
{
fileName=fileList[i];
File fpath=new File(directory+'/'+fileName);
fileSize=fpath.length();
fileDate=fpath.lastModified();
#sql{insert into BLUEUSER.dirlist(filename, filesize, filedate)
values(:fileName,:fileSize,to_date('01/01/1970','mm/dd/yyyy')+:fileDate/(24*60*60*1000))};
}
}
}

CREATE OR REPLACE PROCEDURE BLUEUSER.p_get_dir_list(i_directory IN VARCHAR2) AS
LANGUAGE JAVA NAME 'DirList.getList(java.lang.String)';

SQL> exec BLUEUSER.p_get_dir_list('/tmp');
PL/SQL procedure successfully completed

 

select * from BLUEUSER.dirlist;

select * from BLUEUSER.dirlist where rownum&lt;150;


select filename from BLUEUSER.dirlist where rownum&lt;150;


select filename from BLUEUSER.dirlist;

truncate table BLUEUSER.dirlist;
</filelist>