我沿着这些方向做了一些事:
为要列出的目录创建Oracle目录:
create or replace directory YOURDIR
as '\path\to\your\directory';
构建临时表:
create global temporary table DIR_LIST
(
FILENAME VARCHAR2(255),
)
on commit preserve rows;
grant select, insert, update, delete on DIR_LIST to PUBLIC;
你需要一个java存储过程:
create or replace and compile java source named dirlist as
import java.io.*;
import java.sql.*;
import java.text.*;
public class DirList
{
public static void getList(String directory)
throws SQLException
{
File dir = new File( directory );
File[] files = dir.listFiles();
File theFile;
for(int i = 0; i < files.length; i++)
{
theFile = files[i];
#sql { INSERT INTO DIR_LIST (FILENAME)
VALUES (:theName };
}
}
}
和PL / SQL可调用过程来调用java:
CREATE OR REPLACE PROCEDURE get_dir_list(pi_directory IN VARCHAR2)
AS LANGUAGE JAVA
name 'DirList.getList(java.lang.String)';
最后,在表单中调用过程get_dir_list将使用目录中的文件填充表,然后可以将其读入表单块.
Java代码直接来自Tom Kyte的书(不记得是哪一本).
编辑:
实际上,所有代码都从这个AskTom thread中解脱出来.