How to get the all file names from the folder and move it to another folder
Hello,
How do I read files from a certain directory with PL/SQL, without knowing the exact name ? My application interface with another systems which puts files in a specific directory on the server. UTL_FILE method reads a file when you know the name of the file, but I don't know the name in advance. Is it possible to figure-out the file name ? I also used Tom's method "http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584" (related to Java stored procedure) but am getting error for procedure "ORA-00900: invalid SQL statement". Below is the code that i have used from Tom's forums -
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;
#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) htp.p(p_directory);';
**********************************************************************
exec get_dir_list( '/CERT_XML' );
**********************************************************************
i would like to know is there any alternative approach to retrieve the all file names from the server folder and move those files to another folder?
Thanks
Amit Bhandari