Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to get the all file names from the folder and move it to another folder

Amit BhandariJun 4 2012 — edited Jun 5 2012
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
This post has been answered by ShankarViji on Jun 5 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 3 2012
Added on Jun 4 2012
5 comments
13,107 views