使用PL/SQL获取文件的时间戳 [英] Getting the timestamp of a file using PL/SQL
问题描述
我正在尝试在Oracle服务器的某个目录XYZ中获取文本文件abc.txt的时间戳.该文件可以在一天中的任何时间更新,我必须检查该文件是否在昨天午夜之后的任何时间更新,如果是,我需要将该文件作为附件通过电子邮件发送.
I am trying to get the timestamp of a text file abc.txt in some directory XYZ in oracle server. This file can get updated at any time in the day and i have to check if the file was updated any time after yesterday midnight, if yes i need to email that file as an attachment.
我还有其他方法可以检查吗?
Is there any other way i can check this?
我在互联网上进行了大量搜索,但找不到解决方案. 严重的是不知道如何完成任务.
I have searched a lot over internet but could not find the solution. Seriously not getting a clue of how to get it done.
如果有人可以指导我,那将是很棒的事情.
It would be great if anyone could guide me.
谢谢.
推荐答案
我认为您必须通过编写Java过程来做到这一点,如Tom Kyte在此处所述:
I think you will have to do this by writing a java procedure, as described here by Tom Kyte:
http://asktom .oracle.com/pls/asktom/f?p = 100:11:0 ::::: P11_QUESTION_ID:439619916584
GRANT JAVAUSERPRIV to <your user>
/
create global temporary table DIR_LIST
( filename varchar2(255) )
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[] list = path.list();
String element;
for(int i = 0; i < list.length; i++)
{
element = list[i];
#sql { INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
}
}
}
/
create or replace procedure get_dir_list( p_directory in varchar2 )
as language java
name 'DirList.getList( java.lang.String )';
/
这篇关于使用PL/SQL获取文件的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!