Reading directory names with PL/SQL

I need to reade the names for a given directory, store them and then go through the directory for specific file names. The filenames in the subdirectories are all named the same, however the directory names are different. We're using Oracle 9ir2 and would like to do this within a PL/SQL procedure. The psuedo code goes something like this:
Read directory names for MY_Folder
Place them in a table or cursor
Go through each subfolder and import my_file1, my_file2
How do I obtain the names of all directories?
What's the best way to loop through this list and import my_file1, my_file2?

Hi,
Look at this,
http://www.oracle-base.com/articles/misc/FTPFromPLSQL.php
http://www.oracle-base.com/dba/miscellaneous/ftp.pks
http://www.oracle-base.com/dba/miscellaneous/ftp.pkb
Or Chris Poole's XUTL_FTP package:
http://www.chrispoole.co.uk/apps/xutlftp.htm
Regards,
Christian Balz

Similar Messages

  • File and directory names with Danish characters

    I have installed the Novell Client v2.0 for Linux on my Open Suse 10.3. The Client is connecting to my Netware servers (6.0 & 6.5) without any problems...
    There is one problem... Filenames and directory names with the Danish , & (ae, oe & aa), e.g the filename bger.doc (bger = books) is shown as b. and when clicking the file the file disappears from the file list. It seems to be the same problem with the German (umlaub).
    What to do?
    /Michael

    Originally Posted by J.H.M. Dassen (Ray)
    mimo <[email protected]> wrote:
    > There is one problem... Filenames and directory names with the Danish ,
    > & (ae, oe & aa), e.g the filename bger.doc (bger = books) is shown as
    > b. and when clicking the file the file disappears from the file list. It
    > seems to be the same problem with the German (umlaub). What to do?
    As far as I know, the Novell Client for Linux expects that file and
    directory names use the UTF-8 encoding and does not support a traditional
    8-bit encoding like ISO 8859-1. Try changing the encoding of file and
    directory names to UTF-8 as described in
    SDB:Converting Files or File Names to UTF-8 Encoding - openSUSE
    HTH,
    Ray Dassen
    Technical Support Engineer, EMEA Services Center, Novell Technical Services
    Novell, Inc. Software for the Open Enterprise Software for the Open Enterprise
    Seems a good hint. When I create a folder or file from within SUSE using an "Umlaut" everything is OK and NCL 2.0 displays them correctly as they are UTF-8 formatted.
    The proposed tool is no solution: one cannot convert folders or files that one cannot see (does it work for folders at all?). Maybe a windows tool would work because one could search for all files or folders with "Umlaute" and convert them. Other options?

  • Create directory from procedure using IN parameter-Directory name with path

    Hi,
    I wrote a procedure which takes directory name(C:\temp) as IN parameter and create oracle directory using EXECUTE IMMEDIATE by the procedure. Proc compiled fine but when i try to execute it (exec prc_lx_e_m_fund_activty ('C:\interface','test1.txt','20040102') , i am getting the following error with the execute immediate statement mentioned below.
    create or replace
    PROCEDURE prc_lx_e_m_fund_activty
    i_output_dir IN VARCHAR2,
    i_output_file_name IN VARCHAR2,
    i_interface_date IN VARCHAR2
    AS
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS ' || ''''||i_output_dir||'''' ||';'; -- Where i_output_dir=C:\temp (I am passing this parameter as IN)
    END
    ORA-01481: invalid number format model
    ORA-06512: at "DBO.PRC_LX_E_M_FUND_ACTIVTY", line 326
    ORA-00911: invalid character
    ORA-06512: at line 10
    Process exited.
    Regards,
    Nagarjun.

    You don't need to put it in a string first. Your actual problem was that you included a ";" on the end of your statement which you don't require with execute immediate.
    This would do the job...
    EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS '''||i_output_dir||'''';or this (if you are on 10g upwards)
    EXECUTE IMMEDIATE q'[CREATE OR REPLACE DIRECTORY OUTPUT_PATH AS ''||i_output_dir||'']';However, I would seriously question why you are creating directories dynamically in code.
    The purpose of creating directories and granting permission to read and/or write to them is to maintain security over which users can access various places on the file system. If you give this flexibility of creating directories to users then effectively they can kill your database server and/or hack into information that they shouldn't.

  • I would like to compare a CSV field "Name" with a SQL Server table field "ResourceName" and write out the person that is not in the SQL server table.

    if (this.DataCenterLaborFileUpload.HasFile)
                    var extension = Path.GetExtension(DataCenterLaborFileUpload.FileName);
                    string currentName = "";
                    decimal currentHours = 0.00M;
                    decimal currentFTE = 0.00M;
                    string ResourceName = "";
                    if (extension == ".csv")
                        StreamReader csvreader = new StreamReader(DataCenterLaborFileUpload.FileContent);
                        DataTable dt = new DataTable();
                        dt.Columns.Add("txtName");
                        dt.Columns.Add("txtHours");
                        dt.Columns.Add("txtFTE");
                        while (!csvreader.EndOfStream)
                            DataRow dr = dt.NewRow();
                            var line = csvreader.ReadLine();
                            var values = line.Split(',');
                            if (values[0].Trim() != "Pers.No.")
                                using (DbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLStaffingConn"].ConnectionString))
                                    conn.Open();
                                    using (DbCommand cmd = conn.CreateCommand())
                                        cmd.Connection = conn;
                                        cmd.CommandText = "SELECT ResourceName FROM
    StaffTracking  order by PersonnelResourceType, ResourceName";
                                     //   DbParameter p1 = cmd.CreateParameter();
                                     //   p1.ParameterName = "restype";
                                     //   p1.Value = "Supplier";
                                     //   cmd.Parameters.Add(p1);
                                        using (DbDataReader row = cmd.ExecuteReader())
                                            while (row.Read())
    ResourceName = row.GetString(0);
    if (ResourceName != (values[1].Trim()))
    if (values[1].Trim() == currentName)
    currentHours = currentHours + Convert.ToDecimal(values[9].Trim());
    else
    if (currentName == "")
    dr["txtName"] = currentName;
    dr["txtHours"] = currentHours;
    dr["txtFTE"] = currentFTE + Math.Round(currentHours / (weekdaysInMonth() * 8), 2);
    dt.Rows.Add(dr);
    dt.AcceptChanges();
    currentHours = Convert.ToDecimal(values[9].Trim());
    currentName = values[1].Trim();
                        DataRow drfinal2 = dt.NewRow();
                        drfinal2["txtName"] = currentName;
                        drfinal2["txtHours"] = currentHours;
                        drfinal2["txtFTE"] = currentFTE + Math.Round(currentHours / (weekdaysInMonth() * 8), 2);
                        dt.Rows.Add(drfinal2);
                        dt.AcceptChanges();
                        gvDataCenterLabor.DataSource = dt;
                    gvDataCenterLabor.DataBind();
                    //     Page.DataBind();
    Here is my csv file:
    Pers.No.
    Name
    HomeFID
    Copy Range/Value from Column V
    Worked Date
    Job Code
    Account
    Pay Type
    Activity Type
    Hours
    11111111
    Doe Jane
    USA7064810
    US1-08333.01.08.02.03
    20150223
    00S15H
    9.61E+09
    410
    8
    11111111
    Doe John
    USA7064810
    US1-08333.01.08.02.03
    20150210
    00S15H
    9.61E+09
    410
    9
    11111111
    Smith Jane
    USA7064810
    US1-08333.01.08.02.03
    20150226
    00S15H
    9.61E+09
    410
    8
    So if Doe Jane is not in the SQL table I would like to only display her.
    It's only displaying the ones from the CSV file that are in the SQL Table.
    Thanks

    Hi
    Please use this insert
    code button to provide code next time. It could better to help us to review  your code.
    Now let's focus your question, I have tried to test with your code. But failed.
    I would suggest that you could export columns "Name" and "ResourceName" to DataTable.
    Then use DataTable to compare and filter with its column value.
    Here is a helpful reference:
    Comparingtwo DataTables by specific
    column in C# [closed]
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Use a variable as a table name with NATIVE SQL

    Hi all,
    I am trying to execute a SELECT statement in order to fetch data from an external Oracle DB table to SAP with the following instructions:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM spfli
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    However, I need to indicate the external table name from a variable instead of the solution above. That is, declaring a variable and store the name of the table (e.q. spfli) in it. The resulting ABAP code would be something like:
    EXEC SQL.
      SELECT cityfrom, cityto
             INTO STRUCTURE :wa
             FROM <VARIABLE>
             WHERE mandt  = :sy-mandt AND
                   carrid = :p_carrid AND connid = :p_connid
    ENDEXEC.
    Does anybody know if is possible to do that?
    If not, is there any other solution?
    Thank you in advance

    Yes, as Suhas said, you could use the ADBC API and his class CL_SQL_CONNECTION to achieve this...
    Here is a small example:
    PARAMETERS: p_carrid TYPE spfli-carrid,
                               p_connid TYPE spfli-connid.
    DATA:
      l_con_ref      TYPE REF TO cl_sql_connection,
      l_stmt         TYPE string,
      l_stmt_ref     TYPE REF TO cl_sql_statement,
      l_dref         TYPE REF TO data,
      l_res_ref      TYPE REF TO cl_sql_result_set,
      l_col1         TYPE spfli-carrid,
      l_col2         TYPE spfli-connid,
      l_wa           TYPE spfli.
    CONSTANTS:
      c_tabname  TYPE string VALUE 'SPFLI'.
    * Create the connecction object
    CREATE OBJECT l_con_ref.
    * Create the SQL statement object
    CONCATENATE 'select * from' c_tabname 'where carrid = ? and connid = ?'
           INTO l_stmt SEPARATED BY space.                           "#EC NOTEXT
    l_stmt_ref = l_con_ref->create_statement( ).
    * Bind input variables
    GET REFERENCE OF l_col1 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    GET REFERENCE OF l_col2 INTO l_dref.
    l_stmt_ref->set_param( l_dref ).
    * Set the input value and execute the query
    l_col1 = p_carrid.
    l_col2 = p_connid.
    l_res_ref = l_stmt_ref->execute_query( l_stmt ).
    * Set output structure
    GET REFERENCE OF l_wa INTO l_dref.
    l_res_ref->set_param_struct( l_dref ).
    * Show result
    WHILE l_res_ref->next( ) > 0.
      WRITE: / 'Result:', l_wa-carrid, l_wa-connid.
    ENDWHILE.
    * Close the result set object
    l_res_ref->close( ).
    Otherwise you can also use the FM DB_EXECUTE_SQL...
    Kr,
    m.

  • SRW.SET_PDF_ACTION reference to directory Names with spaces

    Hello,
    I'm trying to create a hyperlink that will spawn a new browser from a PDF report by using the SRW.SET_PDF_ACTION function; however this is not working when my directory structure has spaces in the names
    SRW.SET_PDF_ACTION('C:\"Program Files"\"Internet Explorer"\iexplore.exe www.yahoo.com');
    SRW.SET_PDF_ACTION('C:\Program Files\Internet Explorer\iexplore.exe www.yahoo.com');
    Each of these returns an error - This does work when I place iexplore.exe in folders without spaces.
    Any suggestions?
    TIA
    Brian

    Acrobat does not support automation of the Reader-extension process by any method. It is a feature which Adobe reserve solely for their LiveCycle server product range.

  • Directory name with trailing question mark

    Oracle Linux 5.7 64bit running under Virtual Box
    Trying to remove an empty directory, instead of removing it, it simply renamed it with a non-printable character. I normally do this with 'rm -fR mydir' but decided to expand a bit and use rmdir instead.
    [oracle@vblnxsrv03 db_1]$ pwd
    /u01/app/oracle/product/11.2.0/db_1
    [oracle@vblnxsrv03 db_1]$ cd ..
    [oracle@vblnxsrv03 11.2.0]$ rm db_1
    rm: cannot remove `db_1': Is a directory
    [oracle@vblnxsrv03 11.2.0]$ rmdir db_1
    [oracle@vblnxsrv03 11.2.0]$ pwd
    /u01/app/oracle/product/11.2.0
    [oracle@vblnxsrv03 11.2.0]$ ll
    total 4
    drwxrwxr-x 2 oracle oinstall 4096 Jun 26 17:49 db_1?an 'ls -b' showed 'db_1\r'
    so, what's going on here?

    Dude wrote:
    What happens if you press the <tab> key to expand the name, for instance:
    <pre>
    rm -r db_1<tab><Return>
    </pre>
    What happened? Perhaps the directory was created by a shell script that was created under MS Windows and moved to Linux without converting proper line endings. Windows uses \r\n line-breaks. Linux and Unix uses only \n.Yes, the directory was created from a shell script originally written in notepad on the host Windows os, and placed in a folder that was defined as a 'host share' to the guest Linux server. But when I open that script in vi on the linux server, it shows no "abnormalities" ... like a "^M" at the end of every line. But this is just one small piece of much larger process that has had me running in circles for several days now, so I couldn't swear to all the details leading up to this. I do vaguely remember opening one of the shell scripts in vi and manually deleting that '^M' from every line instead of using 'dos2unix', so maybe I did shoot myself in the foot.
    haven't been able to reproduce the problem in a controlled test. How do I delete this directory now? Tried both rmdir and rm -fr, with the bogus name in both single and double quotes. Neither command complained, but also did not remove the directory.
    Edited by: EdStevens on Jun 28, 2012 10:18 AM

  • Firewall issue with centralized SQL server - port 52384

    Hi, 
    I have dedicated, centralized MS SQL 2012 server for our internal infrastructure with few instances. There is dedicated named instance SC for SC Family Products running on TCP port 1435. Also Server Browser running on UDP 1434 is enabled. I'm trying to install
    SCOM 2012 R2. I got to the step Configure the Operational Database and here, I encountered a problem. I try to connect to my SQL server and put into
    Server name and instance name SQL\SC and into SQL Server port 1434 or 1435, it doesn't connect. If I turn off firewall on SQL server, it connects without problems. On SQL server, I already have allowed incoming communication on ports UDP 1434
    and also TCP 1433-1436. Than, I found out, that I need to allow in TCP 135 so I did it. It didn't work. Than I allowed TCP 49154-49157 for reporting services - it still didn't work. Last thing I allowed (using Microsoft Network Monitor) was TCP port 52384
    and suddenly, it worked . 
    I know what UDP 1434 and TCP 1433-1436 are for. Also, I understand why I have to open 135 and 49154-49157. But I am pretty confused by the port 52384 - what is it for ? Why it isn't mentioned in documentation ? I am pounding with this problem for a while,
    and also, I found out, that my SC VMM is not working, if I do not allow all of these ports - so, probably not only used by SCOM ? 
    Can anyone explain what's that port for ? Or why it's not enough to open 1434, 1433-1436, 135 and 49154-49157 ?
    Thanks
    Tomas

    Hi,
    I didn't install SCOM yet. I am stuck at installation, till I figure out why port 52384 needs to be opened.
    1. My SQL Server Configuration Manager is set like this:
    Protocols for SC - TCP/IP Enabled
    IP2
    Active : Yes
    Enabled : Yes
    IP Address : ipv4 ip address of server
    TCP Dynamic Ports :   (blank)
    TCP Port : 1435
    So, that should be ok, right?
    2. If I turn off firewall on SQL, everything connects ok - so based on that, I suppose that SCOM server firewall is configured ok . It's issue on SQL.
    On SQL server, I have these inbound rules:
    COM+ Network Access (DCOM-In) - TCP 135 enabled
    HTTP/HTTPS - TCP 80,443 enabled
    SCOM Reporting - TCP 49154-49157 enabled
    SQL UDP ports - UDP 1433-1437 enabled
    SQL TCP ports - TCP 1433-1435 enabled
    SCOM 52384 - TCP 52384 enabled <- this is the port I don't understand, why it should be opened
    If I disable any of these rules, my connection will not pass. I figured out those ports using Microsoft Network Monitor on SQL server.
    3. Those databases do not exist yet. I am stuck at 3th step of Operations Manager Setup - at Configure the operational database.
    There are fields Server name and instance name, SQL Server port, Database name, Database size, Data file folder, Log file folder
    . First two are writable and the rest is greyed out. If I don't turn off firewall and I don't enable all rules from point 2 on SQL server and than put in the SQL server name with instance (SQL\SC) and port 1434 (or 1435) it gives
    me red cross, and rest of the page stays greyed out - so, it's unable to connect. If I turn off firewall, or enable all the rules in previous point (2) I am able to change name of the database, database size, data/log file folder. But if I disable any
    of those ports, it stays greyed out - I am concerned about port 52384, why it should be opened? What is it for? Why it isn't mentioned in any documentation? Or am I doing something wrong?
    Thanks
    Tomas 

  • How to Read file name which we are dealing with ODI File tool

    Hi,
    We are using ODi10g version and we have requirement to move file from one place to another place. We are using ODIFileMove utility but we also want to read file name.
    Any help.
    Thanks in Advance.

    You can accomplish this with a fairly simple Jython script.  Use the os.listdir(<directory>) command to get the name of files in a given directory. 
    You can then (still in the Jython script) loop through the files and move them to a desired location (bypassing the OdiFileMove tool) OR use the Jython script to write the file names to a SQL table.  Then, use an ODI procedure to loop through the newly inserted records and store the file name in an ODI variable that you can then use in your OdiFileMove tool etc.
    I often refer to this blog entry from Gurcan Orhan as a starting point for this kind of task: Loading multiple files with ODI | Gurcan Orhan&amp;#039;s Oracle Data Integrator Blog

  • Read files in directories with PL/SQL

    Hi
    Is there any way to read files (just the names) in a directory just using PL/SQL? I mean, finding out the files with .dat extension in a given directory, for example.
    Thanks

    I don't know Forms but I know SQL*Plus and Oracle database. Normally PL/SQL running on the database can only access files on the host where the database instance is running even if you start PL/SQL with a SQL*Plus connection from another host.
    PL/SQL runs only the database instance not on the client side even if you start the PL/SQL code from a remote connection with SQL*Plus.

  • Problems with spaces in file or directory names and Word.exe

    Hi
    I'm trying to open a file with Word from my java aplication, and I have a problem with some file/directory names.
    I have this
    String cmd = "c:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE" + " " + path;
    try {
    Runtime.getRuntime().exec(cmd);
    } catch (Exception errorea){ }
    Here is what happens:
    if path is something like this: "c:\people\info.doc" , there's no problem, Word opens the document, but if path contains blank spaces somewhere, it doesn't work. For example:
    path = "c:\Documents and Settings\info.doc"
    path = "c:\Hi everybody\info.doc"
    path = "c:\tests\test results.doc"
    with the above examples it doesn't work :( Word tries to open "c:\Documents", "c:\Hi" or "c:\tests\test".
    Can anyone help? thanx a lot ! : )

    Hint: use the variant Runtime.exec(String[] args).
    Create a command array, with each token in a separate argument. The entire filename with spaces goes into one argument.

  • Why do I get a class conflict between the Prepare SQL.vi and the Get Column Name.vi with the SQL Toolkit compatibility vis from the Database Connectivity Toolkit?

    I have done extensive programming with the SQL Toolkit with LabVIEW versions through 6.1. My customer now wants to upgrade to Windows 7, so I am trying to upgrade to LabVIEW 2009 (my latest purchased version) using the Database Connectivity Toolkit, and the SQL Toolkit Compatibility vis. Everything seemed to be going okay with the higher level SQL operations, but I ran into trouble with the Get Column Name.vi. 
    The pictures below show the problem. The original SQL Toolkit connected the Prepare SQL.vi with the Get Column Name.vi with a cluster of two references, one for connection, and one for sql. The new compatibility vis have a class conflict in the wire because the Prepare SQL.vi contains a cluster with connection, and command references, but the Get Column Name.vi expects a cluster with connection and recordset references. 
    How do I resolve this conflict?
    Thank You.
    Dan

    I've never worked with the old version of the toolkit, so I don't know how it did things, but looking inside the SQL prep VI, it only generates a command, and the the column name VI wants a recordset. I'm not super familiar with all the internals of ADO, but my understanding is that is standard - you only have the columns after you execute the command and get the recordset back. What you can apparently do here is insert the Execute Prepared SQL VI in the middle and that will return what you need.
    I'm not sure why it worked before. Maybe the execute was hidden inside the prep VI or maybe you can get the column names out of the command object before execution. In general, I would recommend considering switching to the newer VIs.
    Try to take over the world!

  • Batch Reading with Custom SQL

    Hello,
    Queries
    1. Is it possible to use Batch Reading in conjunction with Custom Stored Procs/ SQL?
    2. Is it possible to map an attribute to a SQL expression (like in Hibernate we have formula columns mapped using the formula* property)?
    Background
    1. We use Toplink 11g (11.1.1.0.1) (not EclipseLink) in our application and are controlling mapping using XML files (not annotations).
    2. We are migrating a legacy application with most of its data retreival logic present in stored procedures to Java.
    3. I am effectively a newbie to Toplink.
    Scenario
    1. We have a deep class heirarchy with ClassA+ at the following having a one-to-many relation with ClassB+ and ClassB+ having a one-to-many relation with ClassC+ and so on and so forth.
    2. For each of these classes the data retreival logic is present in stored procedures (coming from the legacy application) containing not so simple queries.
    3. Also there are a quite a few attributes that actually represent computed values (computed and returned from the stored procedure). Also the logic for computing the values are not simple either.
    4. So to make things easy we configured toplink to use the stored procedures to retreive data for objects of ClassA+, ClassB+ and ClassC+.
    5. But since the class heirarchy was deep, we ended up firing too many stored procedure calls to the database.
    6. We thought we could use the Batch Reading feature to help with this, but I have come across documentation that says that it wont work if you override toplink's queries with stored procedures.
    7. I wrote some sample code to determine this and for the heirarchy shown above it uses the speicifed Custom procedure (I also tried replacing the stored procs with custom SQL, but the behavior is the same) for ClassA+ and ClassB+, but for ClassC+ and below it resorts to its own generated SQL.
    8. This is a problem because the generated SQL contains the names of the computed columns which is not present in the underlying source tables.
    Thanks
    Arvind

    Batch reading is not supported with custom SQL or stored procedures.
    Join fetching is though, so you may wish to investigate that (you need to ensure you return the correct data from the stored procedure).
    James : http://www.eclipselink.org

  • MimeBodyPart.getFileName() returns file name with directory path.

    Hi
    The documentation says getFileName() returns filename ,not including directory components. But it is returning
    path like Eserv generic/mails/a.html. Can it return a full path in some mail servers?
    Please respond.
    Thanks

    The documentation says getFileName() returns filename ,not including directory components.I think you must be misinterpreting the documentation. Where did you read that?
    The getFileName method returns whatever the sender sent as a file name. The send should
    send only a simple file name, with no directory components, but they can send anything, and
    you should protect against abuse before using such a file name.

  • Purpose: to create photo galleries to insert or not items: 1) with phocagalery, it works 2) with the transfer via lightroom, I do not see the downloaded files but if I want to create a directory folder with the same name, he said he is already, I see noth

    purpose: to create photo galleries to insert or not items:
    1) with phocagalery, it works
    2) with the transfer via lightroom, I do not see the downloaded files but if I want to create a directory folder with the same name, he said he is already, I see nothing in the media in content management
    Can you help me

    Mahsa21,
    We are glad that we were able to resolve the international calling plan issue for you.  If you need assistance,please  reach out to us.
    thanks,
    Tonya D.

Maybe you are looking for