|
|
|
|
|
|
|
|
|
Re: How to get the file name from directory [message #572491 is a reply to message #572488] |
Wed, 12 December 2012 07:00 |
Solomon Yakobson
Messages: 3275 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
It is possible without java. One way is external procedure. Same like java solution you will have to write code but in, let say C. But unlike java solution you will have to make small changes to listener (add extproc library). Second solution is for all versions supporting DBMS_SCHEDULER. You would submit a EXECUTABLE type job which would spool directory listing to a file (using sequence generated value in file name to make it unique), wait till job completes and read listing from that file.
SY.
|
|
|
Re: How to get the file name from directory [message #572529 is a reply to message #572491] |
Wed, 12 December 2012 23:31 |
mvmkandan
Messages: 68 Registered: May 2010 Location: Trivendrum
|
Member |
|
|
CREATE GLOBAL TEMPORARY TABLE dir_list ( filename VARCHAR2(255) )
ON COMMIT DELETE ROWS;--create the java proc
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 )';
BEGIN
get_dir_list ('/application/prods/temp');
END;
select * from dir_list ;
Execute the above code... final select query will list the filelist from the folder '/application/prods/temp'.
Veera
[Updated on: Thu, 13 December 2012 02:13] by Moderator Report message to a moderator
|
|
|
Re: How to get the file name from directory [message #572550 is a reply to message #572529] |
Thu, 13 December 2012 02:10 |
|
Michel Cadot
Messages: 68658 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
You are a cheater, this is T. Kyte code and you post it in an unreadable way.
In addition, OP said "I tried with Asktom dirlist but java is causing some issue."
You are welcome to post and answer but
1) read what has been posted and do not repeat,
2) when something is not from you post its origin and grant the creator.
Regards
Michel
[Edit: typo]
[Updated on: Fri, 14 December 2012 04:20] Report message to a moderator
|
|
|
|
|
|
|