oracle列目录的可行性测试

2024-08-18

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

上一篇:煤矿安全要从红线意识抓起下一篇:小学美术欣赏评述教案