oracle列目录的可行性测试
oracle列目录的可行性测试 篇1
文章作者:4 N T 1
经过本人测试,确实可行,解决了 kj021320文章的遗憾,kj021320在文章>最后说,当然这个方法缺点就是你要知道WEB路径.少费话,直接贴
code:
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
{
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<150;
select filename from BLUEUSER.dirlist where rownum<150;
select filename from BLUEUSER.dirlist;
truncate table BLUEUSER.dirlist; 好啊 要不然是追加.
测试环境:oracle 9+redhat
【oracle列目录的可行性测试】推荐阅读:
去掉oracle字段的默认值06-05
Oracle06-18
完全卸载Oracle数据库的方法08-30
ORACLE问题08-07
Oracle数据08-20
Oracle恢复10-03
Oracle表分区07-10
Oracle数据仓库09-28
铝锂合金项目可行性报告目录06-01
ORACLE体系结构05-11