How to get all the names of files in the folder and move it to another folder

Hello
How to read the files in a particular directory with PL/SQL, without knowing the exact name? My application interface with another system that puts the 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 output the name of the file? I also used the method of Tom "http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:439619916584" (related to the Java stored procedure) but am getting error of procedure "ORA-00900: invalid SQL statement. Here's the code I used Tom - forums

CREATE or REPLACE AND compile java source named 'DirList '.
AS
import java. IO;
import java.sql. *;

public class DirList
{
Public Shared Sub getList (string directory)
throws SQLException
{
Path = new file (directory);
List of strings [] = path.list ();
Element string;

for (int i = 0; i < list.length; i ++)
{
item = list;
#sql {INSERT INTO DIR_LIST (FILENAME)
{VALUES (: element)};
}
}

}
/
**********************************************************************
CREATE OR REPLACE PROCEDURE get_dir_list (p_directory in VARCHAR2) AS java language
name ' DirList.getList (java.lang.String) htp.p (p_directory) ";
**********************************************************************
get_dir_list exec (' / CERT_XML');
**********************************************************************

I would like to know is there any alternative approach to retrieve all the names of the files in the folder of the server and move these files to a different folder?

Thank you
Amit Bhandari

Hello

It is a limitation of UTL_FILE in Oracle that we can do with Java stored procedures in Oracle.

We can read the files in Server directory using the following steps:

Please follow the steps below:

1. creating a Type of Type Varchar2.

  CREATE OR REPLACE TYPE file_list AS TABLE OF VARCHAR2(255);

2. next, we need create a library of Java file

CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ListVirtualDirectory" AS
  import java.io.*;
  import java.security.AccessControlException;
  import java.sql.*;
  import oracle.sql.driver.*;
  import oracle.sql.ArrayDescriptor;
  import oracle.sql.ARRAY;

  public class ListVirtualDirectory {
    public static ARRAY getList(String path) throws SQLException, AccessControlException {

    Connection conn = DriverManager.getConnection("jdbc:default:connection:");

    File directory = new File(path);

    ArrayDescriptor arrayDescriptor = new ArrayDescriptor("FILE_LIST",conn);

    ARRAY listed = new ARRAY(arrayDescriptor,conn,((Object[])directory.list()));
  return listed; }}

The most advanced method overrides by removing information about java.properties of exception management settings. You can do this by catching the exception thrown in native mode and rethrow it or ignore it. The example it up again.

3. then, you must create a Wrapper function:

CREATE OR REPLACE FUNCTION list_files(path VARCHAR2) RETURN FILE_LIST IS
LANGUAGE JAVA
NAME 'ListVirtualDirectory.getList(java.lang.String) return oracle.sql.ARRAY';

4 grant permissions to the Driectory:

BEGIN
  DBMS_JAVA.GRANT_PERMISSION('USER_NAME'
                             ,'SYS:java.io.FilePermission'
                             ,'C:\JavaDev\images'
                             ,'read');
  END;

5. then you can read the contents of the directory

SELECT column_value FROM TABLE(list_files('C:\JavaDev\images'));

That displays all the files in the mentioned directory.

Thank you
Shankar

Tags: Database

Similar Questions

  • How to get all the style of paragraphs and their policies of an indesign file and write all the info with info para in a txt file with scripts

    @

    How to get everyone how to get all the style of paragraphs and their policies of an indesign file and write all the info with info para in a txt file with scriptingstyle and their policies of an indesign file and write all the info with info para in a txt file with scripts

    Hello

    Try this,

    var doc = app.activeDocument,
        pstyles = doc.allParagraphStyles,
        report = "";
    for(var i =0;i
    

    Kind regards

    Cognet

  • How to get all the icons on the desktop after installing xp

    After installation of xp only recycle bin makes its appearance. How to get all the other program on the desktop icons?

    Like internet explorer, my computer...

    Hello

    How to create a shortcut on the desktop?

    If the item is located in the start menu:

    1. click on start. The start menu appears.

    2 find the item that you want to create a shortcut. If the element is in a submenu of the menu, go to the submenu.

    3 right click on the element. A context menu is displayed.

    4. click on send to. A submenu appears.

    5. click on desktop (create shortcut). XP creates a shortcut to the item.

    _____________________________________________________________________________

    Here is the vista forums

    Try the xp forums at the below link for any other question of XP

    http://answers.Microsoft.com/en-us/Windows/default.aspx#tab=4

    Answers by topic

  • How to get all the fonts in the paragraph?

    Hi all

    Especially in Indesign Javascript list how to get all the fonts section (without a loop in each character).  For example, I used "Minion Pro" to the first character and all other characters are "Zapf Dingbats" fonts. I use code below to get the paragraph font. But it shows only first typeface. If multiple fonts are used for including the paragraph then I need all the list fonts or result "undefined".

    var myPara = app.selection [0] .paragraphs [0];

    Alert (myPara.appliedFont.FontFamily);

    Thank you and best regards,

    Robert S

    var myPara = app.selection [0] .paragraphs [0];

    Alert (myPara.textStyleRanges.everyItem (.appliedFont));

  • How to get all the users of the IOM, whose field Manager is not null or empty

    Hello world

    How to get all the users of the IOM, whose field Manager is not null or empty (using java code)

    Thank you

    Published by: user11205212 on January 18, 2010 12:38 AM

    Hey beginner,.

    I come to write this line where he can put his sql query... in the next post I provided the example sql also...

    Concerning
    VM

    Published by: user12280771 on January 18, 2010 22:11

  • How to get all the names a table display

    Hi all
    I try to get the names of all the points of view of a table. I tried to use the user_views table, but there is no column by specifying the name of the table.
    Is someone can you please tell me how I can get all the names display in a table.

    Thank you

    You will need to join with USER_VIEWS USER_DEPENDENCIES for the list of dependent views on a particular table.

  • How to get all the SMS messages?

    Hi all

    I want to get all the SMS messages in my application, but I can only find the API to get the mails.

    I have search the Forum and know the method of listening to SMS messages, but not to get all SMS messages in the Inbox.

    Can someone help me? Thank you.

    I'm afraid you cannot access the SMS Inbox and not either, you can manipulate the messages as soon as they reach the Inbox.
    However, as you already mentioned, you can listen to them on their way to the Inbox.

  • Satellite L500 - can I get all the instruments and the driver for Win 7?

    good then I got this Toshiba Satellite L500 with Intel... its installed with Windows Vista Home Premium...

    The first problem I had with it was that the Toshiba programms stoped working and reformatting the drive and put it back, then I 'solved' this part...

    Now, the second is that RUNDLL32.exe stops working after that the pc started motor pump and the computer stops responding or becomes slow...
    I tried to format the drive but is still of problems.... more the toshiba programms are defective...

    After research I did his seems to have a place of Vista so I asked of upgrade me to windows 7 and then I also had a few questions?:  :|

    1. is it possible to get all the programms Toshiba Windows 7, flash cars, webcam etc.

    2 does windows 7 run all the programms vista only?

    3 - is so great that I heard?

    Thank you! {for your help, I really need some help... thank you: 8}

    Hello

    I put t know why you have software problem with the Vista OS preinstalled but my Toshiba tools and utilities work fine! Once the control buttons stopped working, but I could fix it reinstall the VAP.

    Back to your question:
    Yes, you can get all the Win 7 drivers and tools for the L500 series. Why not?
    If you would take a glance on the Toshiba page you would find all the stuff for download!

  • Get all the layers and apply to other documents

    Hello everyone,

    I'm copying all layers from one document to the other. But just copy paste is not enough for several reasons (root document may already be closed, copy at a time when the new document is not open yet,...).

    This means that I have to remember all the layers and use them later.

    At the moment I am sth. Like this:

    ---------------------------------------------------------------------------------------

    public static std::vector < PIActionDescriptor > layeractions;

    Sub testGet()

    {

    Result PIActionDescriptor = NULL;

    numLayers Int32;

    SPErr error = kSPNoError;

    DescriptorTypeID typeID = 0;

    Int32 docCounter = 1;

    error = PIUGetInfoByIndex (docCounter,

    classDocument,

    keyNumberOfLayers,

    & numLayers,

    (NULL);

    If (numLayers > 0)

    for (int32 layCounter = 1;

    layCounter < = numLayers & & error == kSPNoError;

    layCounter ++)

    {

    error = PIUGetInfoByIndexIndex (layCounter,

    docCounter,

    classLayer,

    classDocument,

    0,

    and result,

    (NULL);

    layeractions.push_back (result);

    }

    }

    Sub testSet()

    {

    SPErr error = kSPNoError;

    Result PIActionDescriptor = NULL;

    for (auto & it: layeractions)

    {

    error = sPSActionControl-> Play (& result, eventMake, he, NULL);

    }

    }

    ---------------------------------------------------------------------------------------

    So what I'm doing, open a doc with some layers. Then testGet(), open new document then testSet().

    But bench always puts "the command 'Make' is not currently available." and error = - 128.

    Hope you get what I'm trying.

    Thanks for any thoughts!

    Who's going to be a difficult path to travel to this topic. Even if you can get all the properties of the active document and the layers within the document, you have not dealt with pixels on a normal layer data. You will need to save this broad as well. And for dynamic objects and linked smart objects... you have a job to do. Any topic of a document is not capable 'get '.

    Trying to cope with this: "document might already be narrow" would be almost impossible IMO.

    Remember, the source document, which is now closed I now want to copy. Then you can do:

    1. open closed source document. (Or make it more if it is already open)

    2. for each layer in the source document

    a. Select the layer

    b. copy of the document target

    3. close source document.

    The Get accessor routines are not for 'read' directly. You must get the interesting bits of information on and then use the game code that you found using listener.

  • How to trace all the functions and variables Movie Clip

    How can I find all the functions and variables available Movie Clip?  Thank you

    Use the describeType() function.

  • I find no 'organise pages' in the new adobe.  How can I delete the pages and move them in a PDF document? I can't find this service, and when I click on edit PDF learn more page appears saying to add/delete/move pages there is a cost per year? It's always

    I don't see how to move and delete pages in the new adobe.  The previous version had a small page icon on the left and when you clicked it you could click the pages and move them.  Or press Shift Ctrl D to delete pages.

    Now, I do not find it on the new Adobe - or can not find this button "organize" in the toolbar or under Tools.

    When I click the button Edit, it leads me to a page telling me that there is a fee a year to move/remove/add pages.

    You can move and delete pages with Adobe Acrobat, not Acrobat Reader.

    You can buy Adobe Acrobat.

  • How to get all the names of the fields from a tcResultSet

    Hi, im a connector to write to a file all the fields of the form encoding process.

    to be like this:

    User ID: username value
    First name: First name value
    Name: LastName value

    I'm using the Process key instance for the tcResultSet.
    I know that if I give a table or list the field names hard-coded, I can get the field values.

    Like this

    String fieldname = "FORM_UDF_USR_ID";
    String response = formData.getStringValue (fieldName);

    My question is, how can I get a list of the names of the fields in the tcResultSet so I don't need to provide
    something like

    formdata.getFieldlist ();?

    Thank you.

    tcResultSet userSet = userIntf.findAllUsers (userMap);
    If (userSet.getTotalRowCount ()! = 0) {}
    String [] columns = userSet.getColumnNames ();
    for (int i = 0; i)< columns.length;="" i++)="">
    Logger.Debug (columns [i] + ":")
    + userSet.getStringValue (columns));
    }

    Who give a shot.

    -Kevin

  • How to get all the stage within a group or sequence names?

    Hello

    I want to show all the steps within a sequence or group names.

    I wonder if there is a simple function that can be used directly, for example RunState.PreviousStep.Name.

    I tried via a stupid way to add the name of each stage, if it shows all the stage names, but I still think that there is a simple function can access all the stage names.

    Can anyone give me any suggestions, thanks a lot!

    I fiddled a little towards the top of your sequence.  But yes, you have a loop.

    Also, what format you want names?

    Hope this helps,

  • How to get terminate the status and the number of all the steps performed in Teststand

    Hello! Could someone teach me, pls?

    1. motion:

    How can I get the status of the completed sequence?

    Purpose:

    I want to finish execution sequence while something bad happened, so I want to acquire the terminated Staus.

    My action:

    I add a step to the ActiveX API in a reminders file, called SequenceFilePostStepFailure, but I can't get the right value

    2 query:

    How can I get the number of all the steps performed in the cleaning of a sequence?

    Purpose:

    I want to get the number of all executed steps include setup, hand and cleaning, after I closing sequence

    My action:

    call a variable of RunState.NumStepsExecuted. but it just the number of steps performed to Setup or main or cleaning, not all.

    Thank you in advance!

    Review the attachment for more information of the termination.

    For the steps you want to know how much record results or just the total number of steps for the execution? Also, do you need to know how many steps in subsequences were executed?

    Hope this helps,

  • How to GET all THE PHOTOS TAKEN at 300PPI

    How define the rebels T4i (650 d) so all the pictures taken are 300 ppi?

    I guess you got a request for a person to provide images to "300 ppi.  I get these from time to time.

    Images is not "PPI" (or sometimes referred to as "IPR").  Digital images have simply 'resolution', described as the number of pixels in width by the number of pixels high.

    PPP and DPI means "pixels per inch" (or "dots per inch", as it is sometimes called) and refers to a resolution to a specific display size.  But since you can take your camera image and post it to ANY SIZE you want, the custom of the image really have 'PPI' until you choose a physical output size to use for the display of the image.  The camera cannot know in advance the great that will be.  You can take two images in a row, decide to print one as a 4 x 6 "and print another as a 16 x 20" - the camera does know what you plan to do with the image - and more important still, it shouldn't have to. "

    Suppose an image is (I'll do simple numbers) 300 pixels wide by 200 pixels high.   If you were to print this image in a tiny size.... say 1.5 "wide by 1", then you could print at 200 dpi because it is the number of pixels you can align in just an inch.  If you decide to print the same image 3 "wide by 2" high then even the image would be now 100 ppi - and still you has not changed the data from the camera at all... everything you changed was the size of the media output.

    The real resolution of your camera sensor is 5184 x 3456.  So when someone says that they need a 300 PPI image, what you have to say is ' what physical size? (in inches - since its pixels per INCH and not pixels per centimeter, etc.).

    The PPI is managed by the software from your computer when you export a copy of your image for a PRECISE THAT USE of the image.  You don't want to modify your original image data - you want to create a copy of the image to give to this person who wants to display their specific image dimensions and the ppi.

    One other thing... There is also a notion of the ratio of the image.  Your camera natively produced a 3:2 image - which means that the sensor is 50% wider than it is tall.  A 4 x 6 "print maintains this same image ratio.  But note that if you look at other sizes of a 5 x 7 or 8 x 10, the ratio is no longer maintained.  This means that you have to manually crop the image to the ratio that you plan to use when you print (or indication) the image.

    The essential is that only a display of output has a notion of "PPP"... you can 'print' to a given PPP or you can display on a monitor at a given PPP, but the camera image has no such concept because it is not yet displayed.

    The process of cropping, re-sampling and export an image so that it will be a few specific when, PPI to the purpose is of size is all managed by software on your computer - and not by your camera.

    BTW, you can define metadata in an image with a PPI value.  It is not the actual data - just meta-data.  He "suggests" to a printer (which could completely ignore these data if she wants to) the PPI that you want to use when printing.  In other words if my image happens to have the resolution of 1800 x 1200 a meta-data of the 300 dpi value, then a printer that does not circumvent the data will end up with a 6 "x 4" image.

Maybe you are looking for