Change directory path dynamically using UTL_FILE

I have a directory TEST_DIR which points to /test/files/
CREATE OR REPLACE PROCEDURE file_exist (v_country in varchar2) is
v_check_file_exist BOOLEAN;
v_dir VARCHAR2 (256) := 'TEST_DIR';
begin
UTL_FILE.fgetattr (V_DIR || V_COUNTRY,'file123' ||'.txt', v_check_file_exist, v_a,v_b);
IF NOT v_check_file_exist THEN
DBMS_OUTPUT.put_line (TO_CHAR(from_date,'YYYYMMDD')||'.rds');
END IF;
END LOOP;
I would like to change the directory path based on the country which is passed as input to the procedure
exec file_exist('IND'), so in this case I want the procedure to look for file 'file123.txt' under path /test/files/IND.
But this is not working..
But when I change the directory to
create or replace directory TESTDIR as '/test/files/IND' and then change my UTL_FILE.fgetattr (V_DIR,'file123' ||'.txt', v_check_file_exist, v_a,v_b)(removing || v_country, this time it works.
am trying this as I have many country folders under the path like
/test/files/IND
/test/files/USA
/test/files/AFR
and want to change the direcotry path dynamically according to input given.
Any suggestions

Make sure that the directories you are trying to write to have been set up for UTL_FILE.
Refer to UTL_FILE_DIR parameter or CREATE DIRECTORY privilege depending on what DB version you are on.
HTH
--Johnnie                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Change Directory Path using Dynamic Configuration

    Hi,
    We have a requirement where the directory path for placing the files is different across our different environments. Ex: Development Environment has a different path than the Quality Enviornmnet. Also the full path is depending on fileds within the message.
    I want to use Dynamic Configuration to create the Directory path. But in order to capture the full requirement I need to know wheich environment I am within the User Defined Function.
    Can someone provide me the java class and function that I can use in my UDF to read the environment I am in.
    ( Essentially I want to read Sy-SYSID in ABAP...using Java. )
    Regards,
    Arunava

    Hi Arunva,
    >>Essentially I want to read Sy-SYSID in ABAP...using Java.
    It might not be possible to read system id in java, but you can read the sender or receiver service(SENDER_SERVICE or RECEIVER_SERVICE) and based on it can decide the diretory in DynamicConfiguration.
    If you have a sender or receiver SAP sysem then better to read its name because this business systm ill haeunique name aross different environment. Check this thread too
    User-defined function: RFC call
    Regards
    Suraj

  • How to change download path when using webutil_file_transfer.DB_TO_CLIENT

    I am trying to change the path when downloading a file using the download_db procedure (webutil_file_transfer.db_to_client).
    Thanks,
    Terry

    Is the procedure DB_TO_CLIENT built in oracle?
    I also want to download video files from Oracle to client and save to d:\video, How can I do?
    Appreciate for your any words.
    If you know, Plz email to:
    [email protected]

  • Changing a path dynamically in a MathScript node

    I have inherited a MatLab script that must be run in LabView. The first issue I have is creating unique paths. When a Unit Under Test runs, its data will be saved to a file based on the serial number of the UUT. The MatLab script then analyzes the data from that file and creates a new file based on the serial number with a new file extension. Therefore, I need to read in a file whose path changes and write a file whose path changes. The relative path will be the same but the unique file will not. I am looking for suggestions on how to do this since there will be hundreds of serial numbers being tested. It would be nice if the node could have an input that could configure to a path or string type instead of a scalar only. The serial numbers will be apha-numeric and this must be able to exist as a stand alone application.
    Also, the node reports a 'unexpected token: function'. I am noticing that functions must be a seperate .m file but how do you call the function after that?
    I am using LV 8.5
    Thanks - Jeff
    Message Edited by j.masse on 07-07-2008 07:57 AM

    Hello Jeff,
    Creating unique paths is not difficult in MathScript.  Simply pass in the string you want to use as the specific part of the path and have a local variable contain the base path.  For example, if you have a string input named serial to the MathScript node, the following code will build a path:
    basepath = 'c:\data\';
    filename = [basepath serial];
    You mention needing to do this for a large number of files.  The easiest way to do this is to have your loop in LabVIEW and simply pass in one string at a time to the MathScript node to do your processing.  If there is a lot of setup work involved before the work that needs to be done for each file, then it is more complicated.  There really isn't a concept of an array of strings in the language.  The closest you can get is a cell array containing many 1D character arrays.  However, LabVIEW MathScript does not yet support this construct.
    You can pass in a LabVIEW 1D string array -- the MathScript node input will adapt to the type wired to it.  What it does is create a 2D character array in MathScript.  If not all the strings are the same length, then it will pad the end of the string with zeros.  This presents a problem when you try to use the string as a filename.  However, you can use the strrep (string replace) function to replace the zeros with empty strings.  For example, assuming you have an input variable named serial that is a 1D array of strings and a loop-control variable named index, type
    basepath = 'c:\data\';
    name = strrep(serial(index, : ), char(0), '');
    filename = [basepath name];
    You cannot write a function inside of a MathScript node.  What you can do is create a .m file on disk and add the directory to your MathScript search path.  The default search path is your "My Documents\LabVIEW Data" directory.  But if you add the file elsewhere, there are three ways to set the search path for MathScript.  First, from the MathScript Window, go to "File >> LabVIEW MathScript Properties" and click on the "MathScript: Search Paths" category item.  This will set the search path for the MathScript Window only.  Second, from a LabVIEW VI, go to Tools >> Options and click on the "MathScript: Search Paths" category item.  This will set the search path for all VIs in the main application instance only.  Third, from within the project explorer, right-click on "My Computer" and select Properties.  Then click on the "MathScript: Search Paths" category item.  This will set the search path for that context only.  Since you are talking about using this in a built application, the third option will likely be what you need.
    As for using a built application generally, as long as you avoid any MathScript function that describes itself as being unsupported in the run-time engine, you should be okay.  The help for individual functions will list if they are unsupported.  You can see a list of all such functions by looking in the LabVIEW help index for "MathScript" and double-clicking on the entry for "functions not supported in Run-Time Engine."
    Grant M.
    Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments

  • How to change company logo dynamically using login information of the user in flex4 CSS styl method?

    hi all,
    I am doing mxml flex4 web application. i am using a login in my application. this login for multi user  purpose.
    My need is when a user login using his username and password his company logo should show the top of my application and his copyright details show the bottom of my application
    if another user login means his company logo and copywrights should show in my application.
    This logo and copyrights details should change dynamically based on the login information.
    I want to create this using CSS file (skins and sparks)
    How to do this,i am struck in this place,
    Looking for useful and helpful suggession or snippet code,
    Thanks in advance,
    Cheers,
    B.Venkatesan.

    If the user is logging in, presumably you are having the user hit a back end web-server and database and using something like Blaze to connect? Right?
    I personally would not do this with CSS. I would map the company icons to the users in the DB, retrieve the proper company icon and then pass it down (or embed it in the app) when the user logs in. Then, I would just set the source of the icon to be what I passed down:
    Add your image where you want it to go:
    <s:Image id="emptyImage" x="locationx" y="locationy".../>
    Then in your ActionScript, when the user logs in and you know what company the user belongs you could do this:
    private function loginUserBlazeResponse(resultEvent:ResultEvent):void {
    var bytes:ByteArray = ByteArray(resultEvent.target);
    emptyImage.source = bytes;
    addElement(img);
    img.visible = false;
    img.addEventListener(FlexEvent.UPDATE_COMPLETE, imageLoaded);

  • Hi!!!Can anyone suggest how to change data block dynamically using input

    Hi all,
    Here is my requirement...I have a datablock which has 7 columns, these coloumn represent dates. I have a header in which I will input the date[b] from and to ( this is restricted to not more than one month). Now when I enter these 2 date fields in header, My 7 coloumn data block need to be changed to 'n' number of coloumn( which is less than 1 month) as per input fields. Can I do this, if we can then please give me the guide lines.
    Thank you

    it is a good solution Jeneesh, because it is the only one.
    You cannot create items dynamically at runtime, so you have to create them in your form at designtime and show and hide them.

  • Is it possible to change the path color using the pen tool?

    I know we were able to in the past but can we now>

    Here is a quick step by step on how to draw a path and stroke it with color:
    Choose the pen tool to draw a path.
    Draw your path. Below, you can see the path I drew with the pen tool.
    You then want to select the color of the path, which is the "set foreground color" block. (you can see it above in step 1, a few tools below the pen tool). Below you can see the color I selected, then click OK.
    Then select the Direct Selection Tool, you can see it circled in red below.
    Then right-click the path you drew with the direct selection tool. Select "stroke path".
    The stroke path dialog is brought up, you can select the tool form. I selected the pencil for this example.
    Below you can see the path stroked with the color and the pencil tool I selected.
    Other helpful related links:
    if you have any questions, feel free to post back.
    enjoy,
    janelle

  • FTPs connection error:When using Variable substitution for Directory path

    Hi
    I am transferring data from BI to xml file via PI: Here a Client proxy from BI sends the data to PI and the PI FTPs the XML file to a remote location. For FTP I am using FTPs SSL connection.
    It was working fine untill I used Variable susbstitution to determine Directory path dynamically. I am using this because different xml files are intended to goto the different locations.
    I did the variable substitution like this:
    Target Message Structure:
    ---> Target Directory: %var1%
    <?xml version="1.0" encoding="UTF-8" ?>
    <MT_BI_EXTRACT_FILE>
      <Header>
         <Directory>/Customer</Directory>
    </Header>
    <Detail>
    </Detail>
       </MT_BI_EXTRACT_FILE>
    And in the variable substitution I am doing it this way
    payload:MT_BI_EXTRACT_FILE,1,Header,1,Directory,1
    And the error I am getting is:
    Attempt to process file failed with Error when getting an FTP connection from connection pool: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: iaik.security.ssl.SSLException: Peer sent alert: Alert Fatal: handshake failure
    MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error when getting an FTP connection from connection pool: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: iaik.security.ssl.SSLException: Peer sent alert: Alert Fatal: handshake failure
    Exception caught by adapter framework: Error when getting an FTP connection from connection pool: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: iaik.security.ssl.SSLException: Peer sent alert: Alert Fatal: handshake failure
    Delivery of the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Error when getting an FTP connection from connection pool: com.sap.aii.af.service.util.concurrent.ResourcePoolException: Unable to create new pooled resource: iaik.security.ssl.SSLException: Peer sent alert: Alert Fatal: handshake failure.
    Does anybody have some Idea of this ??
    Regards
    Naina

    Hi,
    I guess the problem is not with Variable Substitution..
    Error when getting an FTP connection from connection pool:
    So its a connection problem..
    Also check the option Disable Security check and try again...
    Try to check again if the interface is executing properly without Variable substitution and let us know..
    Babu
    Edited by: hlbabu123 on Jan 7, 2011 2:46 PM

  • How to assign directory path of File/FTP adapter into a variable insideBPEL

    Hi,
    i need to get the directory path given to file/Ftp adapter (write/PUT) into a variable while invoking, which will be later used in some other BPEL service for processing.
    i am able to get the directory path easily using "jca.file.filename/jca.ftp.filename" in case of invokin Read\GET adapter but am struggling to get these details while invoking a file/Ftp adapter (write/PUT).
    kindly tell me is it possible to get these properties in case of file/Ftp adapter (write/PUT) !!!!
    Thanks
    Siva

    These documents may be helpful in discovering the functionality/use of variables to capture some of the file adapter properties.
    How to Manipulate SOA 11g Adapter Headers Using Oracle Mediator (Doc ID 1352248.1)
    How to Create an Outbound File with the Same Name as the Inbound File with FTP/FILE Adapter (Doc ID 745587.1)
    Hope it helps!
    Amy

  • Accessin Access Database it changes the path by itself???

    Hi to all. First of all I would like to apologize about the "zombie resurection". Sorry i didn't know.
    I'm doing what HK_Developer said, but it doesn't work.
    This is my code:
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //Connection con = DriverManager.getConnection("jdbc:odbc:c:xxx.mdb", "myusr", "mypwd");
    // or
    Connection con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (.mdb)};DBQ=C:/xxx.mdb","myusr","mypwd");
    // i tried boths ways
    Statement stat = con.createStatement();
    stat.execute("select from articulos");
    catch(Exception e){ jButton1.setText(e.getMessage());
    jTextArea1.setText(e.getMessage());}
    I don't know what is wrong but it gives me a message saying (more o less) that "o:/yyyy.mdb" is not a valid path. I don't know why it changes the path i use in the "getConnection" parameters. I don't kow where it cacth the "o:/yyyy.mdb".
    Thank you very much.

    I finaly found the solution. My mistake.
    The database i am accessing have some linked tables to another database. My statement is querying one of this tables. That is because te system returns me the message with another path.
    Sorry. I'm newbie.
    Thanks to all.

  • Can't figure out directory/path

    I can't figure out what "directory/path" to use on my FTP Server Settings.
    I know my website address. This is my first time using iWeb.
    Whenever I test the connection I get the message "Testing failed. The directory/path couldn't be found. Verify your settings and try again."
    Can anyone help? Is there a standard format based on the website address?
    John

    I found a workaround.
    I had the same problem. My website URL is called:
    http://www.softtenebraslux.com
    In my FTP site, all files are contained within the www/ directory.
    If I give a name to my website inside iWeb, there is no way I can publish to www/. No way. Whatever I put in Directory/Path, with or without /. It always create a directory with the site name and put everything inside it. I often ended up with my site being published in:
    http://www.softtenebraslux.com/SoftTenebrasLux
    where "SoftTenebrasLux" is the content of the field "site name" with blank spaces replaced by underscores.
    On the other hand, you can't leave the field "site name" blank. So, I simply put "www" in the site name field, and iWeb will indeed publish to my correct directory (that is, www/). Of course, in iWeb, the site entry name is "www" which is stupid. But at least, I can publish with FTP, which works now fine.
    Waiting for a fix for this stupid bug.

  • Dynamic Configuration - Set Directory Path for File Receiver Adapter

    Hi Experts,
    I have a question regarding the dynamic configuration for the file adapter. Is it possible to set a directory path without a message mapping for the file receiver adapter? the problem is that I want to import a pdf document. this pdf document I want to store in a dynamic directory (depending on the filename). so I have to read the filename out of the dynamic configuration and generate (depending on the filename) a directory for this file. Is that possible without a message mapping? I cannot make a message mapping because the file has the pdf format and should not get changed.
    best regards
    Christopher Kühn

    Hi Gaurav,
    I use the ASMA (respectively the filename) for the sender adapter. After the pdf was imported into XI this filename is in the ASMA.
    But what then??? How can I get this filename with the help of the variable substitution? and if I have this filename I have to change this filename a bit to generate the name / path of the directory.
    Please explain it to me detailled
    Thanks and regards
    christopher

  • Changing physical path in FILE TCODE using ABAP CODE

    Hi all ,
    I want to change physical path linked to logical path in TCODE FILE dynamically using ABAP program. Is it possible.
    If yes then how?
    Thanks for your help.
    Regards,
    Uday.

    s

  • How to change the JCA JNDI dynamically using FTP Adapter

    We have 5 FTP Servers, each having a directory to poll. We have created 5 CCI instances for these FTP Adapters in the FTPAdapter deployment. We created a BPEL process and using FTP Adapter to connect to above mentioned servers.
    Question: Customer's requirement is to use a single BPEL process to poll all these FTP Servers at a specified date and time. How can we connect dynamically to each FTP server at specified time.
    (OR)
    Is there any way to change the JCAJNDI dynamically in a FTP Adapter configuration ?
    I have seen that FTP Adapter POLL doesnt take any JCA JNDI/hostname/un/pwd/date/time dynamically.
    Regards
    Pavan

    Hi Pavan,
    It's possible to change the JNDI dynamically but only when you use put operation where you can control the JNDI name at the time of invoking the FTP Adapter as described in below link.
    Dynamic JNDI in FTP Adapter | jca.jndi property not picked by Adapter
    However, can you consider using BPEL process with SyncRead (and read files through all the JNDIs in a loop) and scheduling this BPEL process to a desired frequency?
    Regards,
    Neeraj Sehgal

  • UTL_FILE errors,  invalid directory path ???

    Hi All,
    I am trying to create a csv output file through pl/sql.
    However i am having some issues since its my first time.
    Please have a look at the following code:
    create or replace
    PROCEDURE amer_main_proc (start_sent_date date,
                        end_sent_date date,
                        senttype number) IS
    CURSOR main_cur IS
    SELECT
              s.sent_id,
              s.ussc_id,
              s.sent_upd_date,
              s.alt_docket,
              s.amend_year,
              s.def_num,
              s.dep_status_code,
              s.var_status_code,
              s.disp_type_code,
              s.docket,
              s.oth_sent_code,
              substr(s.oth_text,1,100) oth_text,
              s.po_code,
              ind.prim_offn_code,
              s.prob_mons
    FROM      sentences s,
              submission sub,
              ind_sent ind,
              defendants def,judges j
    WHERE      s.sent_id = sub.sent_id
    AND      s.sent_id = ind.sent_id
    AND      ((sub.case_type_code in (10,11) 
    AND      trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (10)  AND trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (11) AND trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (11) and  s.amend_code = 10 AND trunc(sub.create_date) between start_sent_date and end_sent_date))
              AND s.def_id=def.def_id
              AND s.ao_judge_id = j.ao_judge_id
              AND sent_creator_id is not null
              AND dist_id != 99
    ORDER BY s.ussc_id, s.sent_id;
    --Define output file variables
    out_file UTL_FILE.FILE_TYPE;        /* file type */
    path_name VARCHAR2(50);            /* file path */
    file_name VARCHAR2(50);            /* file name */
    line_buffer VARCHAR2(2000);        /* store all the elements that make up one line in the output file */
    BEGIN
        path_name := 'C:\SQL';  // this folder does exist in my C drive
        file_name := 'main.txt';
        out_file := UTL_FILE.FOPEN(path_name, file_name, 'W');
        line_buffer := 'data main;';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        line_buffer := 'infile cards delimiter='','';';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        line_buffer := 'input ' ||
        'USSCIDN ' ||
        'ALT1DOC $ ' ||
        'DEPART ' ||
        'VARIAN ' ||
        'DISPOSIT ' ||
        'DOCKETID $ ' ||
        'TYPEOTHS ' ||
        'TYPEOTTX $ ' ||
        'POOFFICE $ ' ||
        'MONOFFTP ' ||
        'PROBATN ';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        FOR main_cur_rec IN main_cur LOOP
         --Writes to file
              line_buffer := main_cur_rec.ussc_id ||
              ',' || nvl(main_cur_rec.alt_docket,' ') ||
              ',' || nvl(to_char(main_cur_rec.dep_status_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.var_status_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.disp_type_code),' ') ||
              ',' || nvl(main_cur_rec.docket,' ') ||
              ',' || nvl(to_char(main_cur_rec.oth_sent_code),' ') ||
              ',' || nvl(main_cur_rec.oth_text,' ') ||
              ',' || nvl(to_char(main_cur_rec.po_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.prim_offn_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.prob_mons),' ');
              UTL_FILE.PUT_LINE (out_file, line_buffer);
         END LOOP;
         --Write SAS footer
         line_buffer := ';';
         UTL_FILE.PUT_LINE (out_file, line_buffer);
         line_buffer := 'run;';
         UTL_FILE.PUT_LINE (out_file, line_buffer);
         --Close file
         UTL_FILE.FCLOSE(out_file);
    EXCEPTION
    -- Write error messages to the screen and file
        WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,50));     // this is line 106
        UTL_FILE.PUT_LINE(out_file, SUBSTR(SQLERRM,1,50));
       UTL_FILE.FCLOSE(out_file);
    END amer_main_proc;I know I am having issues regarding the path, please have a look at the ERRORS below:
    Error starting at line 1 in command:
    DECLARE
      START_SENT_DATE DATE;
      END_SENT_DATE DATE;
      SENTTYPE NUMBER;
    BEGIN
      START_SENT_DATE := '01-JAN-2001';
      END_SENT_DATE := '01-MAR-2001';
      SENTTYPE := 10;
      AMER_MAIN_PROC(
        START_SENT_DATE => START_SENT_DATE,
        END_SENT_DATE => END_SENT_DATE,
        SENTTYPE => SENTTYPE
    END;
    Error report:
    ORA-29282: invalid file ID
    ORA-06512: at "SYS.UTL_FILE", line 878
    ORA-06512: at "USSC_CASES.AMER_MAIN_PROC", line 106
    ORA-29280: invalid directory path
    ORA-06512: at line 10
    29282. 00000 -  "invalid file ID"
    *Cause:    A file ID handle was specified for which no corresponding
               open file exists.
    *Action:   Verify that the file ID handle is a value returned from a
               call to UTL_FILE.FOPEN.thanks guys.
    Edited by: Rooney on Feb 20, 2012 12:29 PM

    You'll need to create an Oracle Directory object that contains 'C:\SQL' and use that in your UTL_FILE call if you are using a 10g+ version of the database and the UTL_FILE_DIR parameter does not include your path.
    CREATE DIRECTORY my_dir AS 'C:\SQL';
    GRANT READ WRITE ON DIRECTORY my_dir TO <user>;You can then use the directory object name in the path of your UTL_FILE call.
    ORA-29280: invalid directory path Cause: A corresponding directory object does not exist.
    Action: Correct the directory object parameter, or create a corresponding directory object with the CREATE DIRECTORY command.>
    Hope this helps!

Maybe you are looking for