List files stored in a Directory Object

Hi,
I looked on Google, on Oracle DB docs and here to find a convenient way to list files stored in a DIRECTORY for batch loading in a table with PL/SQL. But no luck, UTL_FILE doesn't seem to have a method for directory listing. I saw examples with some workaround like putting files list in a text file prior to loading. The directory is feeded by other process and network services, so I don't know the filelist that I need to import and, then delete. I dont have access to the server console and it's impossible for me to dump a kind of «dir» result into a text file. I saw other examples using Java, but it looks like I don't have access to Server Side Java too.
Is there a simple way to do that in PL/SQL only?
If not, I'll ask to the DBA the necessary rights to compile/run java on the server side...
The DB target versions for this requirement are 10g and 11g (mainly) on Windows environment.
Thanks
Bruno

brlav35 wrote:
The XUTL_FINDFILES seems to be the more convenient way. If that works for you, I certainly have no objection. In a lot of environments, though, that package would be problematic.
1) It must be installed in the SYS schema. That's generally frowned upon and lots of sites would never allow user code to go into the SYS schema. Chris is a bright guy, so I'm sure the risk of it causing harm is minimal (most likely during an install or upgrade), and it will almost certainly never cause you harm, but that would be a political show-stopper at a lot of places.
2) The package body is wrapped (if there is a version with the package body in clear text, this point is moot). Again, Chris is a well-respected guy, so I have every confidence that the code is not malicious, but asking a DBA to install a wrapped package you downloaded from the internet into the SYS schema on a production database should generate a crud-load of red flags. This is almost certainly just a theoretical danger, but DBAs and audit compliance regulations care a great deal about theoretical dangers. If someone hacked the web site and uploaded their own wrapped bit of code that had a back door, for example, it would be very hard to catch.
3) Under the covers, the package is querying one of the undocumented X$ views. Oracle is free to change those views over time, which would potentially cause the package to stop working or stop working correctly in some way. If you're developing code for a system that may be around for a number of years, that becomes a concern. It's unlikely that Oracle will change the particular X$ view that is being referenced here over the lifetime of your code base, but it's more than a trivial concern.
4) The package is determining what directories a user has access to, that's not Oracle enforcing the restriction. Probably not too big a deal, but it is probably safer from a regulatory compliance standpoint to be able to rely on Oracle the database enforcing privileges rather than relying on a delivered package to enforce those privileges. It's the difference between telling Oracle via specific grants which directories the JVM can access vs. writing your own wrapper that enforces those restrictions. In the end, the restrictions are enforced, but in one case you're relying on the developers of the Oracle database and in the other you're relying on external developers.
Just to re-iterate-- Chris is a brilliant guy, I don't mean this in any way to impugn him or his code. I am totally confident that his code works, that it works well, and that it will continue to work going forward. My concerns are purely on the political/ regulatory side of things, not on the technical side of things. Technically, I am confident that the code is top-notch.
Justin
Edited by: Justin Cave on Sep 9, 2009 12:38 PM
I wrote this before seeing the last few bits of the exchange where you and Chris already talked about the first point.

Similar Messages

  • Secure ftp of files stored in a directory on the operating system

    Is it possible to secure ftp files directly from the server without first storing them in the flows database? (Apex 3.2; Oracle 10g 10.2.0.4; Oracle Unbreakable Linux 4). If so, are there security issues?

    Hi ,
    Use EPS_GET_DIRECTORY_LISTING
    Refer the below code I have used in one of my assignment.
    DATA:   l_check_msg(50)  TYPE c,
              l_filemask       LIKE epsf-epsfilnam.
      CONCATENATE p_sysid '*' INTO l_filemask.
      CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
           EXPORTING
                dir_name               = wa_ztsifregi-pathname
                file_mask              = l_filemask
           TABLES
                dir_list               = i_files
           EXCEPTIONS
                invalid_eps_subdir     = 1
                sapgparam_failed       = 2
                build_directory_failed = 3
                no_authorization       = 4
                read_directory_failed  = 5
                too_many_read_errors   = 6
                empty_directory_list   = 7
                OTHERS                 = 8.
      IF sy-subrc NE 0.
        CASE sy-subrc.
          WHEN 1.
            l_check_msg = 'Invalid subdirectory'(005).
          WHEN 2.
            l_check_msg = 'EPS_GET_DIRECTORY_LISTING failed'(006).
          WHEN 3.
            l_check_msg = 'Build directory failed'(007).
          WHEN 4.
            l_check_msg = 'No authorization'(008).
          WHEN 5.
            l_check_msg = 'Read directory failed'(009).
          WHEN 6.
            l_check_msg = 'Too many read error'(010).
    *      WHEN 7.
    *        l_check_msg = 'Empty directory'(011).
          WHEN OTHERS.
            l_check_msg = 'Unexpected error from function module'(012).
        ENDCASE.
    Hope this solves your query.
    Regards
    Abhii
    Regards
    Abhii

  • Listing files on the webcontent directory that including .jsp files

    Hi ,
    I want to list all files on the directory that including .jsp files . How can I do this ?
    �f I use the following code in the jsp:
    java.io.File file = new java.io.File(".");
    String[] files= file.list();
    it returns me application server 's directory files. But I want to see webcontent directory files.

    You can use the method of ServletContext - getRealPath() to turn a website relative location into a real place on disk.
    In a generic way:
      <%
        String dir = application.getRealPath(request.getServletPath());
        File jspFile = new File(dir);
        File jspDir = jspFile.getParentFile();
        File[] files = jspDir.listFiles(); 
      %>Cheers,
    evnafets

  • How to list files from a remote directory?

    Hi,
    I have a user interface on a PC that needs to display a directory listing of a remote RT processor.  I don't want to have the RT to use List Directory function and the PC to get this result... I'm sure there's a cleaner way to do that with FTP or DataSocket.  I've tried FTP, but it stalls in FTP Directory Listing.vi.
    Any ideas?
    Thanks!
    Patrick.

    There are a number of reasons why the Directory lister can hang. The best thing to do is try the "FTP browser.vi" found in the example finder. If you have the internet toolkit it will show up if you search for "FTP." In this example program, type in your RT unit's IP address and see if you can browse the directory structure. If it works you can use any portion of this program in your own application. Hope this helps.

  • Listing files on a web directory

    Hi,
    I would like to write an application that looks at a certain web directory and reports when a new file is uploaded onto that directory, and returns the URL of the file. I am looking for something like the 'File' class' listFiles() method, to determine if a new file has been uploaded, but I can't find an analogous funtion for directories on the web. Can someone point me in the right direction here?
    Thanks,
    Chester

    Sorry, I should have searched the forum first.....I found an answer.
    -chester (new to these forums)

  • Issue with List Files option in FTP Adapter-

    Hi All,
    I am getting the following error when I am using the list files option inside FTP adapter. The soa Version I am using is 11.1.1.5
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'FileListing' failed due to: Error in listing files in the remote directory. Error in listing files in the remote directory. Unable to list file in remote directory. Please make sure that the ftp server settings are correct. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    I have configured FTP adapter successfully by giving the following details,
    useSftp –
    username –
    password -
    host -
    port –
    authenticationType –
    preferredCipherSuite -
    and it is working perfectly for getfiles option and it is reading files successfully, but it is throwing error when I am using list files option. I tried this option for listing the files that are in remote directory. Any Help would be appreciated.
    Complete fault
    <messages>
    <input>
    <Invoke1_FileListing_InputVariable>
    <part name="Empty">
    <empty/>
    </part>
    </Invoke1_FileListing_InputVariable>
    </input>
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <bindingFault>
    <part name="summary">
    <summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'FileListing' failed due to: Error in listing files in the remote directory. Error in listing files in the remote directory. Unable to list file in remote directory. Please make sure that the ftp server settings are correct. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
    </part>
    <part name="detail">
    <detail>No such file</detail>
    </part>
    <part name="code">
    <code>null</code>
    </part>
    </bindingFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>
    May 9, 2013 4:32:00
    Edited by: BK574 on May 9, 2013 2:47 PM

    Is this a bug in SOA suite?
    Following are the properties inside JCA file
    <adapter-config name="List" adapter="FTP Adapter" wsdlLocation="List.wsdl" xmlns="http://platform.integration.oracle/blocks/adapter/fw/metadata">
    <connection-factory location="eis/ftp/FTPService" UIincludeWildcard="*.*"/>
    <endpoint-interaction portType="FileListing_ptt" operation="FileListing">
    <interaction-spec className="oracle.tip.adapter.ftp.outbound.FTPListInteractionSpec">
    <property name="PhysicalDirectory" value="*.*"/>
    <property name="Recursive" value="true"/>
    <property name="IncludeFiles" value="*.*"/>
    </interaction-spec>
    </endpoint-interaction>
    </adapter-config>
    Edited by: BK574 on May 10, 2013 6:30 AM
    Edited by: BK574 on May 10, 2013 6:31 AM

  • APEX- How to open world document (and other files) stored in a blob column?

    Hi,
    I have an application developed in Oracle Apex 3.2.1 and RDBMS Oracle 9.2.0.8 (SUN SOLARIS SPARC 64 BITS).
    I have a table called BAC_ARQUIVO, with the following structure:
    CREATE TABLE BAC_ARQUIVO
    (NAME VARCHAR2(4000), /* Name of the file stored in BLOB column */
    SUBJECT VARCHAR2(4000), /* A brief description about this file stored */
    ID NUMBER, /* An identification of this file - It´s a PK column of this table*/
    BLOB_CONTENT BLOB, /* Blob field that store diferent kind of files - XLS, DOC, PPT, PDF, EXE, ZIP, etc);
    MIME_TYPE VARCHAR2(4000) /* Identification about which kind of file is stored on BLOB field */
    The field BLOB_CONTENT of this table can store:
    - Executable files;
    - MS-World Documents (DOC);
    - Zip Files (ZIP);
    - Ms-Excel Files (XLS);
    - Ms-Powerpoint files (PPT);
    - Adobe documents (PDF);
    Actually, in this APEX application, i have developed a interactive Report in which the user can download these files to desktop without problems.
    But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
    My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
    For example, if the file stored in the blob column is ms-word type , so the application will open a MS-WINDOWS application with these file.
    Is it possible?
    I saw in this forum that it´s possible to open a file stored on "/i/" directory, but i need to open the file stored in BLOB column. I don´t want to store the file in operational system of the server.
    Could any one demonstrate to me how it could be done?
    Best regards,
    Sergio Coutinho

    Hi Sergio,
    This link might be helpful:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
    Also refer the BLOB Download Format Mask :
    {message:id=9716335}
    Here I have given the format mask for APEX 4.0, which will slightly differ for 3.2.1 and proposed changes
    in the format mask are:
    1) Format Mask: DOWNLOAD
    2) Content Disposition: Inline
    This will be achieved with it:
    >
    But now, my user would like to know if it´s possible that APEX application can OPEN some of these files stored on this BLOB column WITHOUT download it.
    My user would like to see a hiperlink (or button) that, if pressed/acessed, can open a new page (or a page inside application) with the document. He doesn´t need to edit this oppened file. He only wants to see it.
    >
    Hope it helps!
    Regards,
    Kiran

  • PDF generated in SAP backend to be stored in Cloud Proxy object

    Dear Colleagues,
    We generate the pdf file in SAP backend system and send the pdf as an attachment to email address. Along with this we also want to automatically have this pdf file stored in Cloud Proxy object. So that users can access these files in Cloud portal when needed.
    If anyone has expertise on this topic, please share or suggest the solution.
    Thanks,
    Arun

    Hi Arun,
    Would you like to achieve an automatic way to store the document in cloud portal? Can you elaborate a bit more?
    Check out this blog demoing the documents repository capabilities and read the official documentation here.
    I believe the public folder can fit for your needs.
    Regards,
    Eliel.
    Cloud Portal Development.

  • Recipient list files ?

    What would the @ number be in the messageid for recipient list files in
    ..\offiles ?
    Cheers Dave
    Dave Parkes [NSCS]
    Occasionally resident at http://support-forums.novell.com/

    If you are trying to find the recipient list file in the
    offiles directory, there is not away to do that currently.
    If that what you are ask for?
    Preston
    >>> On Tuesday, May 01, 2012 at 11:07 AM, Preston
    Stephenson<[email protected]> wrote:
    > Sorry, I don't understand what you are asking and in what context.
    >
    > If you want the path to the attachment in the offiles directory,
    > you can specify "ReturnPath" when getting an attachment with
    > getAttachmentRequest.
    >
    > Here is an example:
    > <?xml version="1.0" encoding="UTF‑8"?>
    > <env:Envelope
    > xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema‑instance"
    > xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
    > xmlns:ns0="http://schemas.novell.com/2005/01/GroupWise/methods">
    > <env:Header>
    > <ans1:session
    > xmlns:ans1="http://schemas.novell.com/2005/01/GroupWise/types">hv4Tmcdjv2
    > KVq
    > S5_</ans1:session>
    > <ans1:gwTrace
    >
    xmlns:ans1="http://schemas.novell.com/2005/01/GroupWise/types">false</ans1
    > :g
    > wTrace>
    > </env:Header>
    > <env:Body>
    > <ns0:getAttachmentRequest>
    >
    >
    <ns0:id>4F3A1944.domain.PO1.200.2000000.1.89D.1@45 :4F3A1944.domain.PO1.100
    > .1
    > 776172.1.46C97.1@1:7.domain.PO1.100.0.1.0.1@16</ns0:id>
    > <ns0:offset>0</ns0:offset>
    > <ns0:length>0</ns0:length>
    > <ns0:flags>ReturnPath</ns0:flags>
    > </ns0:getAttachmentRequest>
    > </env:Body>
    > </env:Envelope>
    >
    > <?xml version="1.0" encoding="UTF‑8"?>
    > <env:Envelope
    > xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
    > xmlns:xsi="http://www.w3.org/2001/XMLSchema‑instance"
    > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    > <env:Header/>
    > <env:Body>
    > <gwm:getAttachmentResponse
    > xmlns:gwm="http://schemas.novell.com/2005/01/GroupWise/methods"
    > xmlns:gwt="http://schemas.novell.com/2005/01/GroupWise/types">
    > <gwm:part
    > path="\\pstephenson1.provo.novell.com\data\autotes t\domain\po1\offiles\f
    > d40\
    > 4f3a1944.001"/>
    > <gwm:status>
    > <gwt:code>0</gwt:code>
    > </gwm:status>
    > </gwm:getAttachmentResponse>
    > </env:Body>
    > </env:Envelope>
    >
    > Preston
    >
    >>>> On Tuesday, May 01, 2012 at 10:22 AM, Dave
    > Parkes<DParkes@no‑mx.forums.novell.com> wrote:
    >> What would the @ number be in the messageid for recipient list files in
    >> .\offiles ?
    >>
    >> Cheers Dave

  • File (Directory) object problem?

    Hi there. My problem is as follows. The method below is supposed to access an pre-existing directory with five previously saved test files, read in those files as account objects, add the objects to an ArrayList, then return the ArrayList. It seems to be able to create a file object representing the directory alright but it then insists that there are no files in the directory! Have I fouled up or is there some subtlety that I'm unware of? I was wondering if the fact that the account files have a .bac extenstion had something to do with it.
    Here's the method, with the two lines of code where I think the problem might lie in bold print:
    public ArrayList retrieveAccounts()throws IOException{
    ArrayList accounts = new ArrayList();
    File accDir = new File("C:" + File.separator + "accounts"); //creates a directory object
    //The following S.o.p statements are for test and maintenance purposes rather than user feedback
    System.out.println("Directory " + accDir.getCanonicalPath() + " opened");
    System.out.println("Confirm Accounts directory exists: " + accDir.exists());
    System.out.println("Directory: " + accDir.isDirectory());
    String [] accFiles = accDir.list(); //gets a list of files in the directory and saves it as a String array
    System.out.println("Number of files in directory: " + accDir.length());
    while(i < accDir.length()){
    filename = accFiles;
    try{
    //open layered input Streams to access the next account file in line
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("C:"+ File.separator + "accounts" + File.separator + filename));
    account = (Account)in.readObject();
    accounts.add(account);
    in.close(); //closes Streams for that particular file
    }catch(IOException e){System.out.println("Filing error as follows: " + e);
                }catch(ClassNotFoundException e){System.out.println("Class not Found. Details: " + e); }
    filename = null; //frees up reference for next file
    i++;//counter increments by one
    return accounts;

    This is what I was trying to do minus the comments and maintence and test code:
    public ArrayList retrieveAccounts()throws IOException{
    ArrayList accounts = new ArrayList();
    File accDir = new File("C:" + File.separator + "accounts");
    String [] accFiles = accDir.list();
    while(i < accDir.length()){
    filename = accFiles;
    try{
    ObjectInputStream in = new ObjectInputStream(new FileInputStream("C:"+ File.separator + "accounts" + File.separator + filename));
    account = (Account)in.readObject();
    accounts.add(account);
    in.close();
    }catch(IOException e){System.out.println("Filing error as follows: " + e);
    }catch(ClassNotFoundException e){System.out.println("Class not Found. Details: " + e); }
    filename = null;
    i++;
    return accounts;
    By the way, your the first Java programmer that I've met that doesn't like comments! :)
    NOTE: Think I may have spotted where I went wrong in my code.
    filename = accFiles;
    Forgot to point it at the specific element of the array, like so:
    filename = accFiles[i];
    Thanks for your help!

  • 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

  • Listing of all file names in a directory

    Hello everyone,
    Is there a way to get the listing of all file names in a directory
    pointed by an entry in dba_directory in oracle into a collection in
    pl/sql procedure.
    Thank you.
    Tuncay

    this is the same problem I am trying to solve now. I found some ehlp in Tom Kyte articles on java stored procedures.
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows;
    create 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 procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    then you call in your pl/sql and fill your collection from the DIR_LIST table:
    get_dir_list('the name of the directory' );
    ---then you fill the collection by fetching the DIR_LIST table
    good luck,
    Florin

  • Reg. PDF file stored in oracle server directory

    Dear All ,
    How to stored PDF generated file in oracle server directory.
    Thanks & Regards
    shailesh

    You need a directory object in Oracle for that server directory. That directory needs to be accessible (permission/ACL wise) to the local database processes to read/write from/
    The schema that will be doing the read/write using that directory object, needs read/write privs on it.
    UTL_FILE is used by PL/SQL code to write database contents to file.

  • How to list all files in a given directory?

    How to list all the files in a given directory?

    A possible recursive algorithm for printing all the files in a directory and its subdirectories is:
    Print the name of the directory
    for each file in the directory:
    if the file is a directory:
    Print its contents recursively
    else
    Print the name of the file.
    Directory "games"
    blackbox
    Directory "CardGames"
    cribbage
    euchre
    tetris
    The Solution
    This program lists the contents of a directory specified by
    the user. The contents of subdirectories are also listed,
    up to any level of nesting. Indentation is used to show
    the level of nesting.
    The user is asked to type in a directory name.
    If the name entered by the user is not a directory, a
    message is printed and the program ends.
    import java.io.*;
    public class RecursiveDirectoryList {
    public static void main(String[] args) {
    String directoryName; // Directory name entered by the user.
    File directory; // File object referring to the directory.
    TextIO.put("Enter a directory name: ");
    directoryName = TextIO.getln().trim();
    directory = new File(directoryName);
    if (directory.isDirectory() == false) {
    // Program needs a directory name. Print an error message.
    if (directory.exists() == false)
    TextIO.putln("There is no such directory!");
    else
    TextIO.putln("That file is not a directory.");
    else {
    // List the contents of directory, with no indentation
    // at the top level.
    listContents( directory, "" );
    } // end main()
    static void listContents(File dir, String indent) {
    // A recursive subroutine that lists the contents of
    // the directory dir, including the contents of its
    // subdirectories to any level of nesting. It is assumed
    // that dir is in fact a directory. The indent parameter
    // is a string of blanks that is prepended to each item in
    // the listing. It grows in length with each increase in
    // the level of directory nesting.
    String[] files; // List of names of files in the directory.
    TextIO.putln(indent + "Directory \"" + dir.getName() + "\":");
    indent += " "; // Increase the indentation for listing the contents.
    files = dir.list();
    for (int i = 0; i < files.length; i++) {
    // If the file is a directory, list its contents
    // recursively. Otherwise, just print its name.
    File f = new File(dir, files);
    if (f.isDirectory())
    listContents(f, indent);
    else
    TextIO.putln(indent + files[i]);
    } // end listContents()
    } // end class RecursiveDirectoryList
    Cheers,
    Kosh!

  • How to get file names for one oracle directory object.

    Hi all ,
    I defined one oracle directory object . Now I want to know how many files stored under this object in physical directory and their names ? anyone know how to do it by pl/sql ?
    Thanks,
    George

    Chris Poole has an [XUTIL_FINDFILES package|http://www.chrispoole.co.uk/apps/xutlff.htm] which can do this in pure SQL. It does require, though, that your DBA install code in the SYS schema and that you rely on the behavior of an undocumented X$ table. That may not be possible in certain environments.
    I personally prefer a small Java stored procedure along the lines of [this one from Tom Kyte|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584]. It isn't a pure PL/SQL solution, but it tends to fit relatively cleanly in any environment. Most DBAs will be willing to grant the privileges this sort of approach requires where they would be hesitant to grant the access necessary for XUTIL_FINDFILES.
    Justin

Maybe you are looking for