Traversing through oracle directory in Plsql

Hi experts ,
I want to traverse the oracle directory to search for a particluar pdf file and then convert that pdf file into blob file.
This blob file will be store in the oracle table.
The problem is that the path of the oracle directory will be dynamically set with the variables.
Please guide me for this as i dont't have the enough knowledge about the oracle directory objects.
Any useful link will also be appreciated.
Thanks

Oracle is a database software. Asking it to do OS level operation is in a sense wrong. But such a thing is achievable in oracle if you take the help programming language like C or Java.
Here is a very old post from ASKTOM where in Tom demonstrates how to do a list directory using embedded Java code and with the help of global temporary table.
Ask Tom "reading files in a directory -- how to get a list of available files."
This should get you started. If you have expertise in Java or C you can improvise it, as its a decade old code.
And to load the file into blob column of a table, again I will refer you to an ASKTOM post.
Ask Tom "Display PDF file stored in the Database"

Similar Messages

  • How to write a file in unix server through oracle plsql code

    Hi All,
    My requirement is to create and write a file (any file for eg txt file) in unix box with in a specified directory through oracle plsql code.
    Oracle sits in windows server.
    using utl_file package we can create directory where oracle resides and write it there in oracle server in our case windows..
    But here we need to create,write a file but in unix server which is different server than where the oracle server resides..
    we are using Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    Can any one one please help me out in this issue...
    Thanks in Advance.
    Prakash

    Mr Prakash,
    Why are you asking this question multiple times in every forum you can spell?
    Valid responses have been presented to you already two times.
    Can you explain why you can't follow them up, but continue to abuse this forum by repeating doc questions?
    Sybrand Bakker
    Senior Oracle DBA

  • How to find the number of files in an oracle directory through a storedproc

    hi
    i have an oracle directory or a directory in an ftp server
    is there any way.......through which..
    i can know the number of files in the directory ...?
    and whats the metadatacolumn that will indicate the name of the file?
    and is it possible to loop through each of the entries within oracle
    regards
    raj

    ops$tkyte@8i> GRANT JAVAUSERPRIV to ops$tkyte
      2  /
    Grant succeeded.
    That grant must be given to the owner of the procedure..  Allows them to read
    directories.
    ops$tkyte@8i> create global temporary table DIR_LIST
      2  ( filename varchar2(255) )
      3  on commit delete rows
      4  /
    Table created.
    ops$tkyte@8i> create or replace
      2     and compile java source named "DirList"
      3  as
      4  import java.io.*;
      5  import java.sql.*;
      6 
      7  public class DirList
      8  {
      9  public static void getList(String directory)
    10                     throws SQLException
    11  {
    12      File path = new File( directory );
    13      String[] list = path.list();
    14      String element;
    15 
    16      for(int i = 0; i < list.length; i++)
    17      {
    18          element = list;
    19 #sql { INSERT INTO DIR_LIST (FILENAME)
    20 VALUES (:element) };
    21 }
    22 }
    23
    24 }
    25 /
    Java created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 procedure get_dir_list( p_directory in varchar2 )
    3 as language java
    4 name 'DirList.getList( java.lang.String )';
    5 /
    Procedure created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec get_dir_list( '/tmp' );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i> select * from dir_list where rownum < 5;
    FILENAME
    data.dat
    .rpc_door
    .pcmcia
    ps_data
    http://asktom.oracle.com/pls/asktom/f?p=100:11:4403621974400865::::P11_QUESTION_ID:439619916584
    Edited by: Salim Chelabi on 2009-04-21 10:37

  • Need help writing a script to traverse through files in a directory

    I want to go through a directory and sub directories and convert files into jpg ones
    I have this code I've been using: mkdir jpegs; sips -s format jpeg *.png --out jpegs
    This is great for one directory at a time
    But, what I want is to apply this to all sub directories, create a jpeg directory in each of the sub directories and then create jpg's and put them in there
    I'm not sure where to start
    Should I be looking for 'scripting in linux'?
    Thanks
    Omar

    Hello
    You may also try something like this. Set DIR to the root directory to start the search.
    #!/bin/bash
    #     convert png to jpeg and put jpeg in jpegs sub-directory
    DIR=~/Desktop/test
    while read -d $'\0' f
    do
        d=${f%/*}/jpegs
        [[ -d "$d" ]] || mkdir "$d"
        sips -s format jpeg "$f" --out "$d"
    done < <(find "$DIR" -type f -iname '*.png' -print0)
    In case, here's an AppleScript wrapper:
    set f to (choose folder with prompt "Choose root folder to process")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/bin/bash -s <<'EOF' -- " & f's quoted form & "
    #     convert png to jpeg and put jpeg in jpegs sub-directory
    DIR=\"$1\"
    while read -d $'\\0' f
    do
        d=${f%/*}/jpegs
        [[ -d \"$d\" ]] || mkdir \"$d\"
        sips -s format jpeg \"$f\" --out \"$d\"
    done < <(find \"$DIR\" -type f -iname '*.png' -print0)
    EOF"
    Regards,
    H

  • How to check the files ...that are present in an oracle directory

    hi all
    is there any data dictionary view or table that will list all the files that exist a oracle directory?
    regards
    raj
    we can see all the directories using dba_directories i would like to see what all files it contains
    regards
    raj

    hi justin
    this is me who posted here ..but here i was asking about... the directory that we create in oracle.....
    about dba_directories.....
    in the other post in pl/sql forum i was asking about the directory that exist on the ftp server....... and using unix from with in plsql to loop through the list of all the files
    regards
    raj

  • Need to create file in unix (oracle directory path)

    Is it possible to create a file in oracle directory path (in unix folder).
    I am using a dynamic procedure to create the External Tables, when the given pattern file is present the procedure will create the External table, if the file is not present then it should create an empty file so that the corresponding External table would return zero(0) records. It should not fail.
    It has to be through plsql not using unix script.
    UTL_FILE.FGETATTR(V_DIR_NAME, V_FILE_NAME, V_EXISTS, V_FILE_LENGTH, V_BLOCKSIZE);
    IF v_exists=FALSE THEN
    --------create an empty file
    v_file_name:=empty_file;
    end if;
    --Create table script which will dynamically create the external table
    v_sql := 'CREATE TABLE '||V_RX_NAME||' ( '||RTRIM(v_cols,', ')||' )' ||
    ' ORGANIZATION EXTERNAL '||
    ' ( TYPE ORACLE_LOADER '||
    ' DEFAULT DIRECTORY "'|| v_dir_name || '"'||
    ' ACCESS PARAMETERS '||
    ' ( RECORDS DELIMITED BY NEWLINE '||
    ' LOAD WHEN ( '||RTRIM(v_null_cols,'and ')||')'||
    ' BADFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.BAD''' ||
    ' DISCARDFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.DISCARD''' ||
    ' LOGFILE '''||rec_mkt_name.SUBJECT_AREA_NAME||'_'||rec_mkt_name.PARAM_NAME||'.LOG'''||
    ' FIELDS TERMINATED BY ''~'' OPTIONALLY ENCLOSED BY ''"'' '||
    ' MISSING FIELD VALUES ARE NULL ' ||
    ' ) LOCATION ('''||V_FILE_NAME||''') ) REJECT LIMIT UNLIMITED';
    GV_CURR_STEP := v_sql;
    dbms_output.put_line(V_FILE_NAME) ;
    EXECUTE IMMEDIATE v_sql;
    ...........

    Saubhik wrote:
    Try to use utl_file.fopen with 'W'.Or maybe even with "A", and then close it. If you use "W" it will overwrite the file if it already exists. ;)

  • Processing OS Files in an Oracle Directory

    I have an application that gets XML files and stores them in a directory. I'd like to write a PL/SQL program that I can schedule to process all files in the directory. I won't know at run time what the file names are, so I need a way to somehow loop through all files in the directory, do my processing, and exit when I've run out of files.
    I've been reviewing documentation and it doesn't look like fileGetName or fileExists will work for this type of processing, since they either assume a known file name or return the directory name, which I'll need to specify since there are multiple directories used by this process.
    In pseudo-code, here's what I have in mind:
    declare
    cursor all_files is
    select filename from xml_in; --xml_in is my Oracle directory where the files will live.
    eachFile all_files%ROWTYPE;
    begin
    open all_files;
    loop
    fetch all_files into eachFile;
    exit when all_files%NOTFOUND;
    --Do my XML processing here
    end loop;
    close all_files;
    end;
    Is it possible to do this kind of processing on external files? If so, how can I get something that would function like the cursor described above to work?

    The files are unknown to Oracle, I'm using an Oracle directory just as a save point for processing. I've got an external application written that will process the xml (actually, it calls an already-completed PL/SQL stored procedure) but I'd like to have portability between the different OS's.
    Short answer to your question...No.

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Discover Report  in Viewer through Oracle Apps

    hi,
    I want to launch the Discoverer Report in Viewer through Oracle Apps.
    Through Concurrent Program, by passing some parameters...?
    Do any one havei idea how to do it?
    Thanks in Advance
    regards
    -Seetha

    Hi,
    You can launch Disco Viewer or Plus from the Apps menu by creating an OracleOASIS Application Function.
    If you want to run Discoverer from a Concurrent Program then I assume you want the output of the Discoverer report as an HTML ( or some other format) available as output from the concurrent job. If that is the case then Discoverer Desktop Edition must be used to export the workbook into a file and this can be done from the current manager with a bit of development.
    On our system we have developed a concurrent request to schedule Discoverer workbooks. The main parameters for the concurrent request are the workbook you want to run, the parameters for the workbook, the responsibility you want to use to run the workbook in Discoverer and the type of export you want (ie. HTML, PDF, Excel etc). The concurrent request then sends the request to a Discoverer workstation. A simple VBSript on the workstation runs Discoverer from the command line and exports the workbook to a file to the request output directory back on the database server (using a SAMBA drive). The Discoverer report then can then viewed as output from the concurrent request. However, we mainly use a web page integrated to Apps to view and download output from our concurrent requests. This all works smoothly and provides a better alternative for Applications than using Discoverer scheduling.
    Hope that helps,
    Rod West

  • Creating Sap Crystal Report Through Oracle Stored Procedure Packages

    Hi,   
    1.How we can create crystal report through oracle stored
    procedure packages pls tell me the steps through adding command then
    tell me the syntax what should i write in command to call the stored
    procedure packages or if have some other option then also tell. 
    2.can
    we link stored procedure column to other table column that used in
    report.

    Hi Ganesh,
    As this error comes when you are trying to insert non-numeric value into a numeric column in db it seems that your field might be numeric and you are trying to send it as a string in database.
    Please check your Store Proc carefully..
    Reference Thread: Oracle/PLSQL: ORA-01722
    --Dhana

  • Oracle 10g connectivity with sql server 2000 through oracle transpa gateway

    dear gurus.
    i am to connecto oracle 10g with sql server 2000 through oracle transparent gateway.
    i have installed transparent gateway and proper configured. also link is created.
    but when i execute query "select * from city@inventory" , so an error displayed.
    ORA-12500: TNS:listener failed to start a dedicated server process.
    kindly suggest me what could be the cause.
    regards,

    if the listener fails to spawn a dedicated server process it is commonly indicating an issue with the listener. So posting the listener and also a listener trace including a description of the env where you installed the gateway into which directory would be helpfull. Please keep also in mind if you have for example a 10.2.0.3 database and you install into this directoty a 10.2.0.1 gateway you have to reapply the patchset again do get consistent file version.
    So please describe more detailed your env.

  • Need help  traversing through files

    i have a folder with 99,999 xml files. i need to access each and everyone of these files to look for a certain value.my question is: is there any convenient way of traversing through these files?
    File xmlfile = new File("");
    File onefolder = new File("C:\\Documents and Settings\\drstempprojects\\Desktop\\Compiled\\NLB_Recam");
    String[] arroffiles = onefolder.list();
    for (int i=0;i<arroffiles.length;i++) {
        xmlfile = new File("...\\NLB_Recam\\" + arroffiles);
    this method is inefficient and takes a hell load of memory since we are creating an array of 99,999 strings and using each array slot only once. i'm pretty sure there are better solutions to this. suggestions pls anyone?thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    i'm pretty sure there are better solutions to this. suggestions pls anyoneDon't store 100k files in the same directory.

  • How to give network path while creating oracle directory.

    I have created
    CREATE OR REPLACE DIRECTORY TESTDIR AS '\\168.176.33.117\TESTDIR';
    but through this path i m not able to create text file.
    create or replace procedure WriteTest is
    f utl_file.file_type;
    s varchar2(200) := 'this is some info';
    begin
    f := utl_file.fopen('TEST2DIR','sample2.txt','W');
    utl_file.put_line(f,s);
    utl_file.fclose(f);
    end WriteTest;
    Help how to give network path while creating oracle directory.
    --when i give local machine path then it will create at local machine where oracle is installed. but not able to create at other machine.
    Zakir

    Well for starters your directory object is called TESTDIR and in your fopen statement you are referring to TEST2DIR.
    On top of that I'm not sure oracle is happy to refer to network locations. I think you have to map it to a regular drive mapping (shared directory) type path. Can't say I've every tried to do it though.

  • Insufficient access rights registering Oracle Directory Integration Server

    Hi all!
    following steps I´ve done to use the Oracle Directory Integration Server.(I´ve installed Oracle 10g infrastructure - OID is running - I´m also able to apply successful with ODM and orcladmin account)
    - oidctl connect=mydb1 server=odisrv instance=1 stop
    - odisrvreg -h localhost -p 389 -D cn=orcladmin,cn=Users,dc=localhost;dc=com -w ,pass
    where pass is the password of orcladmin.
    -> now I get the following error:
    registering..
    Error javax.naming.NoPermissionException [LDAP:error code 50: Insufficient Access Rights]; remaining name 'cn=odisrv+orclhostname=maschine,cn=odi,cn=oracle internet directory' !
    Any idea ??
    Thanks for all help & comments.

    I have gone through the documentation for creating the script. But there is one thing which I am not able to understand i.e. Subscription Parameters.
    Can anyone tell me the use of subscription parameters? What is the role of subscription parameters in Oracle Lite and External Authentication.
    Regards
    Kapil

Maybe you are looking for

  • No audio for video files in lightroom 4 ?

    i have been importing video files from my canon 7d into both lightroom 3 and lightroom 4 beta.  the video works great in both, but there is no audio in 4 beta.  Audio works fine in lightroom 3.

  • Thread Pool Size

    What can be the maximum thread pool size used in java. What happens if i put up a thread pool size in range of 10k or 20k. how does affect system performance ??? Its quite urgent for me to know. Can someone help out ??? Regards Hrushi

  • Remove a domain controller when dcpromo bombs

    i'm trying to demote one server in a two server setup i start dcpromo , it gets part way through and then bombs with an "Access is denied" error which is b~@:!hit. Ive tied this 2 or 3 times with known good passwords(see dcpromoui.log below) So how c

  • Problem with 10g agent

    I installed 10g agent on server with 9i database. When agent just started then in Enterprise Manager Grid Control I saw database status (it's up) and some database statistics. It's OK. But after some time about 10 minutes I have got an email with mes

  • What is considered as "Apps" in mac storage

    Hello, I have a 2012 13" macbook air, Its fully functional and I'm very happy with it, however I recently checked out my system storage and noticed that I had 15gb out of apps, however when I checked the application folder, I only got 6gb of apps. No