List directory Files in PL/SQL

I'm trying to list all the files in a Win NT/2000 directory (folder) from a PL/SQL procedure. I'd like to loop through and process each file. Is this possible in PL/SQL? If not is there anyway to accomplish this? Many Thanks

Hello,
U R trying to run an OS commd thrgh PLSQL, well U can do it but through an External Procedure - either using C prog or Java prog (preferd).
Points to get list of files from a directory is as follows :
1. Specify that directory path in init.ora
(ex : UTL_FILE_DIR=d:\Temp)
file for which U want to list files
2. write a Java prog. (preferred) which will list U all files with in that folder.
If more than one file, do concatinate those using a special char & make a single string so that U can resolve that in PLSQL block to seprte files.
a typical java prog which perform what I mensioned is as follows :
import java.io.*;
import java.util.*;
class TestFile
public static void main(String[] args)
TestFile t1 = new TestFile();
String fileNameStr = t1.returnFile();
System.out.println(fileNameStr);
public static String returnFile()
File f = new File ("d:\\Temp");
String str[] = f.list();
int size = str.length;
int i;
String fileName=new String();
if (size!=0)
for(i=0;i<=size-1;i++)
fileName = fileName + "$" + str;
return fileName;
else
return "No File";
This will returns all Files in the d:\Temp folder concatinated with "$" symbol.
3. load that Java prog in Oracle.
create directory pNew as
'd:\Test';
create or replace and resolve java source
named "TestFile" using bfile(pNew,'TestFile.java');
4. create a package in Oracle which call that Java prog.
create or replace package TestFile as
function returnFile return varchar2 is
language java
name 'FileRead.returnFile() return java.lang.String';
end;
SQL>SELECT TestFile.returnFile FROM DUAL;
Note: U should have CREATE ANY Directory Previlage.
Hope this helps, If U find btr soln, do inform & if reqrd frthr soln leave msg in this forum.
regards
Prakash

Similar Messages

  • How we cam naintain different directory file in native SQL

    Hi Friends.
    Pls solve my problem.
    I am writing code using native sql for getting data from different directories as
    first i have only one directory file
    execsql
    SELECT * INTO :WA  FROM file.
    endexec.
    now the costumer has 3 different directory files.
    he need a selection on which he can choose any directory.
    if i used as
    parameters  x type .   for selection screen
    what type i should used and how i use that parameter in Select statement to pass data in WA.
    i am waiting for ur reply.
    regards

    Hi,
    You can place your code inside a loop...endloop.
    Loop at itab into wa_tab.
    exec sql.
    SELECT * INTO :WA FROM :wa_tab-file.
    endexec.
    endloop.
    Regards
    Subramanian

  • JDeveloper  Error listing directory

    Hi, for some reason I'm encountering this kind of error while running an application, I can fixed this issue by going to the directory stated in "Error Listing Directory file" then delete all the contents, but every time I run the application again, it always come to this. Does anyone encounter this issue? I'm using JDEVADF_11.1.1.4.0 on win7.
    IntegratedWebLogicServer startup time: 68317 ms.
    IntegratedWebLogicServer started.
    [09:39:44 AM] ---- Deployment started. ----
    [09:39:44 AM] Target platform is (Weblogic 10.3).
    [09:39:46 AM] Retrieving existing application information
    [09:39:46 AM] Running dependency analysis...
    [09:39:46 AM] Deploying 2 profiles...
    [09:39:51 AM] #### Deployment incomplete. ####
    [09:39:51 AM] Error listing directory file:/C:/MyRoot/SS/1.2.3/portlet_apps/system11.1.1.4.37.59.23/o.j2ee/drs/ViewMyBill/ViewWebApp.war/WEB-INF/classes/com/proj/util/ss/base/viewMyBill/model/ServiceName/WXServicePkg/ServiceInfo/
    #### Cannot run application AccountAddressInfo due to error deploying to IntegratedWebLogicServer.
    [Application ViewMyBill stopped and undeployed from Server Instance IntegratedWebLogicServer]
    Thanks.

    I think the problem is that this directory name is too long for windows.
    To fix this you can set your JDeveloper user directory home to point to a shorter path (like C:\temp) see info here:
    http://download.oracle.com/docs/cd/E21764_01/install.1111/e13666/ojdig.htm#BDCJCHDF

  • List all file names in a directory

    Hello everybody,
    I need to write a script in PL/SQL (oracle 10g) that lists all filenames in a specific directory on a client machine and import the files into the database (xml files). After the file is imported they have to be removed.
    I was searching for a solution for this because I have never come accross a challenge like this.
    What I found was that I could use the procedure dbms_backup_restore.searchfiles of the SYS schema.
    Now I need to know how this procedure works. There is very little documentation available.
    Can I give the procedure a folder name on my client computer that has the xml files and let the procedure list these files?
    Can someone please help me with this. I haven't got a clue.
    Thanks in advance.
    regards,
    Mariane

    Hello Justin,
    Thank you for your reply.
    You have just confirmed what I already was thinking: that the server cannot read files from the client.
    I haven't got a client application running to do this. My customer wants me to write a script in PL/SQL that enables users to run an import of xml files in the database by giving in a directory name on the client.
    I told my customer that they have to put the xml files on a server directory. Should that always be the server where the database resides on?
    Is there another way to solve this request?
    Thanks in advance.
    regards,
    Mariane

  • Get list of files in a directory

    Hello everybody,
    working with Oracle 9.2 I have created a directory and i would like to implement in pl/sql a procedure that return the list of files contained.
    Anybody know the general solution for this matter?
    Thanks in advance

    Tom Kyte has an example:
    Directory List including modify date and times

  • Get file list of directory files from URL ?

    Hello,
    GIven a URL directory, I would like to get a list of all the files in that URL directory:
    url = new URL("http//www.example.com");
    c = url.getContent();
    // Suppose there is a file http://www.example.com/myfile.txt
    // How do I get a list from c?
    Essentially, I want something equivalent to the File "list" method
    file = new File("H:/tmp");
    list = file.list()
    Thanks in advanced.

    Crosspost: http://forum.java.sun.com/thread.jsp?thread=518669&forum=17&message=2475782

  • Application Server Directory file attributes lists

    Hi,
    I'm searching for Funtion Module or Method to get Application Server Directory file lists with all attributes.
    1) FM 'SUBST_GET_FILE_LIST' is not getting midifued date and time.
    2) Method CL_GUI_FRONTEND_SERVICES-DIRECTORY_LIST_FILES is getting local directory files.
    I'm looking for standard way to get all attributes whatever we are seeing in AL11 transaction like Name, Length, Creator and last changed date and time stamp-
    ...Nandha

    Hi
    The fm SUBST_GET_FILE_LIST is right but you need to convert the date and time by your self, u can use this routine:
    PERFORM P6_TO_DATE_TIME_TZ(RSTR0400) USING FILE_LIST-MTIME
                                                     FILE_LIST-MOD_TIME
                                                     FILE_LIST-MOD_DATE.
    Max

  • How to list the files I saved in //var/mobile/ApplicatiDocuments directory?

    I want to list the JPG files in the directory of /var/mobile/Applications/XXXXXX/Documents. Have any API like [[NSBundle mainBundle] pathsForResourcesOfType:@"JPG" inDirectory:path]; to list the files? Thanks. Kevin.

    I think you can just do something like this:
    NSArray *paths = NSSearchPathForDirectoriesInDomains
    (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSLog(@"documentsDirectory=%@", documentsDirectory);
    NSArray *docDirContents = [[NSFileManager defaultManager]
    directoryContentsAtPath:documentsDirectory];
    for (NSString *fileName in docDirContents)
    if (![[fileName pathExtension] caseInsensitiveCompare:@"jpg"])
    NSLog(@"fileName=%@", fileName);
    - Ray

  • How to list the files in a directory which are recently modififed few mins

    Hi,
    I need command to list the files in a directory which are modified few minutes ago in SunOS. like "find . -cmin 2 -print " which list files that are modified 2 mins ago in Linux platform.
    Thanks in advance.
    sudha85

    The find command that comes with solaris doesnt have the cmin operator. Only mtime whose option is days.
    So install gnu find from sunfreeware which is the same one that comes with linux.

  • List all files in a directory on a server that hosts the applet

    Hei :)
    I have a problem. I want to list all files in a directory on my server. ( http://www.foo.bar/tw )
    The applet is in the root folder ( http://www.foo.bar ).
    So i tried it like this
    File fi = new URL(getCodeBase() + "/all/").getFile();But when I try to list the files, I get a SecurityException.
    Can anyone help me out?
    Peace!
    LoCal

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Blist+%2Bfile+%2Bserver

  • Problem with getting a list of files in a directory

    I'm trying to get a list of files in a particular directory. The problem is I'm also getting a listing of all the sub-directories too. Here is my code:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int i=0;i<filelist.length;i++)
    System.out.println("FileName = " + filelist.getName());
    What am I doing wrong?
    Thanks
    Brad

    You are not doing anything wrong. You just have to test whether a given file is a subdirectory:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int n = 0; n < filelist.length; n++) {
      if (!filelist[n].isDirectory())
        System.out.println("FileName = " + filelist[n].getName());
    }S&oslash;ren Bak

  • List of Files in directory on AS

    WEBUTIL.DIRECTORY_LIST gives me the list of files on the client. But I need List of Files in directory on App Server . My App server is on LINUX and client is Windows. So How can get through oracle forms a List of Files in directory on Application Server .
    I will appreciate help ?

    I don't know if it helps you(if not excuse me)
    look at
    List of Files in directory on AS
    Running HOST Commands
    If you have a host command of the form:
    HOST ('DEL c:\temp.txt')
    This will work in both client/server and Web deployed environments, but in web
    deployed environments the command runs on the middle tier.
    in Linux ls -la > .....

  • List of Files in a directory

    Is there a way that you can get a list of files in a directory that are spelt a certain way? Ex. If in a directory there are html files, txt files, et, In java can I get *.html or a html file with certain text in the name? java.html??
    How you can Help
    US101

    here are the code to list your files
         File startDir = new File("your directory goes here" );
         File[] dirList = startDir.listFiles();
         if (startDir.isDirectory());
         out.print( startDir.getPath() );
              //Start cycling through the array for the file
         for ( int count = 0; count < dirList.length; count++ )
    String fileName = dirList[count].getName();
              int index = fileName.lastIndexOf('.');
              String newString = null;
                   if (index >= 0)
                        newString = fileName.substring(index, fileName.length());
                        if ( newString.equalsIgnoreCase( ".txt"))
                             if ( dirList[count].isDirectory())
                                  out.println( dirList[count].getName() );
                             else
                                  out.println( dirList[count].getName());
                             }//end else
                        }// end if newstring
         }//end if index
         }//end for

  • List of files in directory

    I need to access a list of files in a directory. The files are .js scripts that I want to dynamically insert into a page with JSP. The problem is that at my company these .js scripts will often be added/removed and it would simplify the process to just look at what's in the directory and pick out the appropriate .js that are available.
    My directory structure is arranged something like this:
    ./src/jsp for the jsp pages
    and
    ./conf/somescripts for the .js scripts.
    I tried accessing it with getClass().getResource() to get the URL, and I also tried File(relativePathToSomescripts) but without much success - tends to get nulls in return. I'm not too experienced with JSP, but I'm guessing the relative paths change once Tomcat compiles them. So what would be a reliable way to access the list of files in the script directory?

    The File constructor only accepts absolute URI's. You can get the absolute URI for the relative URI using ServletContext#getRealPath().
    String absolutePath = servletContext.getRealPath(relativePath);

  • Getting a list of files from a shared directory

    Hi All,
    I need to get a list of files from a shared directory on another server and put them in a HTMLB TableView element with links to the files.
    I was not successful with CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES. This method works in test mode, but gives me a gui_not_supported exception in BSP. I guess BSPs are not allowed to use this.
    Is there any other alternative?
    I need to be able to upload the files as well.
    Thanks,
    Roman
    Message was edited by: Roman Dubov

    Hi again,
    Not sure about the shared directory files list...
    In my opinion, this cannot be done using BSP.
    But, you can try using VBScript to access the file system with object of that sort :
    CreateObject("Scripting.FileSystemObject")
    it is only a thought and you can be sure to cross security problems by accessing files through a Web application...
    Best regards,
    Guillaume

Maybe you are looking for

  • March's TechNet Wiki SSRS Guru Winners announced!!

    The results for March'sTechNet Guru competition have been posted! http://blogs.technet.com/b/wikininjas/archive/2014/04/17/the-microsoft-technet-guru-awards-march-2014.aspx <- results page! Congratulations to all our new Gurus for March! We will be i

  • Ssh forwarded glx problem with older servers

    Hi, I've recently started having problems with displaying OpenGL apps forwarded through an ssh session to an SGI Altix. It seems like it might be an upgrade problem that has also been observed on Ubuntu: https://bugs.launchpad.net/ubuntu/+sour - bug/

  • How to apply signed patches to Studio 11 under Solaris 10?

    I'm running Solaris 10 6/06 on a Sun W2100z (x86_64) workstation. I have a long history of experience with Solaris, but I'm not terribly familiar with the things that are new or different with 10, including zones and the new patch management tools. I

  • Process Chain - Master data Reorganizing and Realignment

    Hello Experts, 1) Could you provide me the best practice on using the Re-organizing the master data for Time independant and time dependant attributes/texts. 2) In addition to attribute change run for Master data attr/hier/texts, how significantly it

  • Why can I not bookmark a particular page?

    I tried to bookmark a webpage butnothing happened when I clicked on bookmarks. The wesite I am trying to bookmark is http://www.stalbanswoodrecycling.org.uk/about.aspx I have had no problems with ither websites