Reading files from different directories and exceuting them

D:\>cd PROC_PKG_FUNC
mkdir FUNCTIONS
mkdir PACKAGES
mkdir PACKAGES_BODY
mkdir PROCEDURES
mkdir TYPES
mkdir TYPES_BODY
SQL> create directory FUNCTIONS as 'D:\PROC_PKG_FUNC\FUNCTIONS';
Directory created.
SQL> create directory PACKAGES as 'D:\PROC_PKG_FUNC\PACKAGES';
Directory created.
SQL> create directory PROCEDURES as 'D:\PROC_PKG_FUNC\PROCEDURES';
Directory created.
SQL> create directory PACKAGES_BODY as 'D:\PROC_PKG_FUNC\PACKAGES_BODY';
Directory created.
SQL> create directory TYPES as 'D:\PROC_PKG_FUNC\TYPES';
Directory created.
SQL> create directory TYPES_BODY as 'D:\PROC_PKG_FUNC\TYPES_BODY';
Directory created.
suppose,
there is a D:\PROC_PKG_FUNC directory in my local machine where the database server exists.
And in that directory there are different directories like FUNCTIONS,PACKAGES,PACKAGES_BODY,PROCEDURES,TYPES,TYPES_BODY, now I've created all the remote schemas obejcts in these folders using utl_file, with the help of the following package
SQL> CREATE OR REPLACE PROCEDURE Get_Db_Ddl_Scripts AS
2 v_file Utl_File.FILE_TYPE;
3 v_file_dir VARCHAR2(50);
4 i_first_line NUMBER := 1;
5 BEGIN
6
7 v_file_dir := 'PROC_PKG_FUNC';
8
9 FOR REC_OBJ IN
10 (SELECT DISTINCT NAME,TYPE,DECODE(TYPE,'FUNCTION','FUNCTIONS','PACKAGE','PA
CKAGES','PACKAGE BODY','PACKAGES_BODY','PROCEDURE','PROCEDURES','TYPE','TYPES','
TYPE BODY','TYPES_BODY') v_file_dir
11 FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE OWNER='FRISKDEVI41B'
12 AND TYPE IN ('FUNCTION, PROCEDURE','PACKAGE','PACKAGE BODY','TYPE'))
13 LOOP
14 v_file := Utl_File.FOPEN(location => REC_OBJ.v_file_dir,
15 filename => REC_OBJ.NAME || '.sql',
16 open_mode => 'w',
17 max_linesize => 32767);
18 i_first_line := 1;
19 FOR REC IN (SELECT TEXT FROM ALL_SOURCE@FRISKDEVI41B_ORCL WHERE NAME = REC_
OBJ.NAME AND TYPE=REC_OBJ.TYPE AND OWNER='FRISKDEVI41B' ORDER BY LINE)
20 LOOP
21 IF i_first_line = 1 THEN
22 Utl_File.PUT_LINE(v_file,'CREATE OR REPLACE ' || REPLACE(REC.TEXT,CHR(10),N
ULL));
23 ELSE Utl_File.PUT_LINE(v_file, REPLACE(REC.TEXT,CHR(10),NULL));
24 END IF;
25 i_first_line := i_first_line + 1;
26 END LOOP;
27 Utl_File.FCLOSE(v_file);
28
29 END LOOP;
30
31 END;
32 /
Procedure created.
SQL>exec Get_Db_Ddl_Scripts ;
PL/SQL procedure successfully completed.
Thus the files are created in the location.
now what i want to do is i want to read each file and run in my current schema to create these objects in my local scehma ,is that possible? Help required._

ORCHYP wrote:
once these files are written in respective folders, you can open them with utl_file('read') in current schema and very well you can execute them.
Try it onceTry it as many times as you like, you won't execute the files with utl_file, that's for sure. ?:|
Using something like DBMS_SCHEDULER you could issue a one off job for each script, as that package can call o/s commands.
However, what's the point?
You may as well, in the code above, just build up your DDL commands or whatever inside your code and, rather than write them out to scripts, use the EXECUTE IMMEDIATE command to execute the DDL against the database.
Of course may not be the best thing to be doing, but we have very little information about what it is that is trying to be achieved, and no reason given why all the functions, packages etc. aren't just put together in a single script that is executed from the command line in the first place. Why try and write PL/SQL to do it?

Similar Messages

  • [Urgent] How to read files from different directories?

    I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
    ProjectDirectory
    |--MainDirectory
    |--MainProgram.java
    |--SupplementDirectory
    |--SupplementProgram.java
    |--Pictures
    |--Image.gif
    What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
    Thanks

    Run through the I/O tutorial here. It should get you up to speed on this sort of thing...

  • How to include header files from different directories?

    Hi,
    Sorry for the newb question, but I can't figure this out. I'm trying to compile a simple piece of code (C++) that uses header files in a directory different from the Project directory; header files are in /opt/csw/postgresql/include/pqxx. I've tried a few different things, adding that directory to the include directives under Resource Files, add existing files from a folder, etc etc. Whenever I try to build, dmake bails with status -1. I can't seem to get this working, can someone explain how to use header files from different directories?
    Thanks,
    SlowToady

    Header files are usually specified relative to a base directory. If the base directory is not a system directory -- /usr/include or the compiler installation directory -- add a command-line directive
    -I path/to/base/dirfor each such directory.
    The path can be absolute, such as
    -i /opt/csw/postgresql/includeor relative, such as
    -I ../../my/includeIn your source code, specify the header file relative to the base directory, and be sure to use quotes, not angle brackets. Example:
    #include "header.h"  // right
    #include <header.h>  // wrongThe angle brackets are used for system headers, like <iostream> or <stdlib.h>.
    The rules above are common to all compilers on Unix and Linux, and generally to all C and C++ compilers.
    For more details, read about the -I option in the C++ Users Guide. You can find the guide by pointing your browser to the "docs" directory in the compiler installation, or go here:
    http://docs.sun.com/app/docs/doc/819-5267
    All command-line options are described in Appendix A.

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • Read files from multiple directories

    Hy to all! I have a little problem with reading files from a hierarchy of directories,something like this: directory A contains: 4 filed and directory B, and also B contains 3 files and 2 directories and so on. i want to make a method that reads all the files from directory A (including all files from subdirectory). I know i have to use recursive programming, i need a method that will be use to do this. Can U help me to do this????? Thank you all.

    Can U help me to do this?Sure. First, review basic File IO in Java: [http://java.sun.com/docs/books/tutorial/essential/io/file.html]
    Second, have a look at the numerous examples available on the Internet: [http://www.google.com/search?q=java+traverse+directory]
    Third, let us know if you run into any specific problems.
    Good luck!

  • Download files from the URL and store them in the table

    Hello,
    I want to download files from the URL and want to store them in the table.
    Can I do it using sql/pl-sql.
    Please help me on this.
    Thanks,
    Rajendra Yadav

    Never tried it before...
    Is this what you are talking about?
    http://www.oracle-base.com/articles/10g/file-upload-download-procedures-10g.php
    Cheers,
    Manik.

  • How use PHP to read image files from a folder and display them in Flex 3 tilelist.

    Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
    PHP :
    PHP Code:
    <?php
    //Open images directory
    $imglist = '';
    $dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "filename: " . $file . "\n";
    $dir->close();
    ?>
    FLEX 3 :
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.rpc.events.ResultEvent;
    public var image:Object;
    private function resultHandler(event:ResultEvent):void
    image = (event.result);
    ta1.text = String(event.result);
    private function faultHandler(event:FaultEvent):void
    ta1.text = "Fault Response from HTTPService call:\n ";
    ]]>
    </mx:Script>
    <mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
    <mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
    <mx:HTTPService id="pic" url="{phpPicture}" method="POST"
    result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
    <mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
    <mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
    </mx:Application>
    Thanks. Need help as soon as possbile. URGENT.

    i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
    PHP Code:
    <?php
    echo '<?xml version="1.0" encoding="utf-8"?>';
    ?>
    <root>
    <images>
    <?php
    //Open images directory
    $dir = dir("images");
    //List files in images directory
    while (($file = $dir->read()) !== false)
    if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
    echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
    //$dir->close();
    ?>
    </images>
    </root>
    Flex Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    creationComplete="callPHP();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.http.HTTPService;
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import mx.rpc.events.FaultEvent;
    import mx.events.ItemClickEvent;
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var arr:ArrayCollection = new ArrayCollection();
    private function callPHP():void
    var hs:HTTPService = new HTTPService();
    hs.url = 'Picture.php';
    hs.addEventListener( ResultEvent.RESULT, resultHandler );
    hs.addEventListener( FaultEvent.FAULT, faultHandler )
    hs.send();
    private function resultHandler( event:ResultEvent ):void
    arr = event.result.root.images.image as ArrayCollection;
    private function faultHandler( event:FaultEvent ):void
    Alert.show( "Fault Response from HTTPService call:\n " );
    ]]>
    </mx:Script>
    <mx:TileList id="tilelist"
    dataProvider="{arr}">
    <mx:itemRenderer>
    <mx:Component>
    <mx:Image source="images/{data}" />
    </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>
    </mx:Application>

  • Reading file from ftp server and importing data into table

    Hi experts,
    Well basically i have text files with different layout that have been uploaded on an ftp server. Now i have to write a procedure to fetch those files, read them and insert data in a table... can that be done?
    your precious help would be greatly helpful.
    Thanks

    declare
    file1 UTL_FILE.FILE_TYPE;
    filename varchar2(1000) := 'GTECHFILES';
    str long;
    begin
    file1 := UTL_FILE.FOPEN (filename,'agent_dump_csv.rep','r',32767);
    loop
    UTL_FILE.GET_LINE ( file1, str );
    --dbms_output.put_line('Value is :'||to_char(str));
    end loop;
    UTL_FILE.FCLOSE( file1 );
    exception
    when no_data_found then
    dbms_output.put_line('END OF FILE');
    UTL_FILE.FCLOSE( file1 ) ;
    when others then
    UTL_FILE.FCLOSE( file1 ) ;
    dbms_output.put_line('ERROR: '||sqlcode||':'||sqlerrm) ;
    end;
    i have managed to write this piece of code and all lines are being read and now i need to insert data into my table and the fields are seperated by a `|` i am strill trying to figure how to do that now. help ...
    Edited by: Kevin CK on 17-Jan-2010 22:40

  • CS3: Any way to Batch convert files from different directories?

    Using CS3. I want to open a bunch of TIF files and re-save using different file options. The only way I know to do this is with File > Automate > Batch. But that only works if the destination folder for all files is the same. It's not.
    Ideally I would not need to first open the files in Photoshop. Perhaps something with Bridge will work. Tools > Photoshop > Image Processor looks promising. There's even an option called "Save in same location", which does not do what it says so is totally useless.

    >Bridge and Finder. They might both be running, but they are two programs that aren't Photoshop to do one simple thing Photoshop should do already by version 11.
    The whole point is that Bridge is supposed to be used as an integral part of the CS4 SUITE.
    I keep Bridge CS4 running at ALL times (it uses a minute amount of resources when it is just in standby mode) and I consider it to be an essential adjunct to Photoshop particularly if you deal with digital camera files.
    I use its "Get Photos from Camera" to download from my card reader in preference to Nikon's download program; and I open whole batches of RAW files for processing in Bridge-hosted ACR 5.2.
    ACR 5.2 also handles scanned Tiffs and JPEGs.
    And I use Bridge to output Web Galleries; attach files to e-mails; collect aliases of all the files of any kind (and from any folder) that are needed for a particular project into a single Collection: and generally to organize file storage throughout my System.
    The only thing that I can't yet do directly from Bridge is to burn a Collection to a CD or DVD.
    Hopefully, someone like David Franzen will create a Script to do that too?

  • How to call java files from different directories

    hi, how do i call java files from a different directory??
    let say i got partA.java, and i need to include functions from partB.java which is in a different folder. how can i do that?

    Chicon wrote:
    Hi nuttynibbles,
    Before the class declaration in partA.java, you must have an import statement like :
    import someDirectory.partB;
    public class partA {
    ... and before you ask... you'll probably want to read through this http://java.sun.com/docs/books/tutorial/java/package/index.html

  • Is there a way to select multiple track sections from different tracks and join them to make the chorus on iPhone?

    I am currently using the iPhone to record my vocals on top of professional beats, or riddims as they are called in the dancehall world. Is there a way for me to select multipe voice sections from different tracks, copy them and then paste them later in the project. I don't want to record the chorus more than once. Normally what I do is sync the project to my wife MacBook Air and then from there edit it but I would like to avoid this. Also, I use the earpods microphone to record my voice and of course it doesn't come out professional quality but it is decent. Do you recommend a microphone that plugs to the iPhone or should I get an interface? Thanks for the help.

    You can either copy and paste single regions or duplicate sections, if you want to copy regions
    from different tracks in parallel. 
    See: Extend a song with song sections
    Adjust the length of your sections in a way, that the regions you want to copy from different tracks are together in a section of your song.
    Add a copy of a section:
    Open the song section controls, choose the section you want to copy, then tap Duplicate.The copy is added after the last section.
    Tap Done to close the song section controls.
    After copying the section, move the new section to the end of the song:
    Change the order of sections:
    Open the song section controls, then tap Edit.
    Drag a section up or down in the list by the handle on its right edge.
    When you are finished, tap Done.
    Tap Done to close the song section controls.
    Regards
    Léonie

  • Downloading image files from the server and saving them on local disk

    Hello,
    In an AIR app. i want to download number of image files,i have paths
    in an array.I am looping through the array and using URLLoader.Format
    is BINARY,now on the complete event of one file i dont know how to
    store the file on the disk as exactly which file has dispatched the
    event is not known.Please point out if my approach is incorrect or if
    any other ideas -plz share.

    Try the following:
    var imgURLs:Array = new Array();
    imgURLs[0] = "http://www.adobe.com/ubi/globalnav/include/adobe-lq.png";
    imgURLs[1] = "http://www.adobe.com/images/shared/download_buttons/get_adobe_air.png";
    var urlRequests:Array = new Array();
    var urlLoaders:Array = [];
    for (var i:int = 0; i < imgURLs.length; i++)
        loadURL(i);
    function loadURL(i:int):void
        var urlReq:URLRequest = new URLRequest(imgURLs[i]);
        urlRequests[i] = urlReq;
        var urlLoader:URLLoader = new URLLoader(urlReq);
        urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
        urlLoader.addEventListener(Event.COMPLETE,                
                    function (event:Event):void
                        var path:String = urlReq.url;
                        var urlLoader:URLLoader = event.target as URLLoader;
                        saveFileData(path, urlLoader.data);
    function saveFileData(path:String, data:ByteArray):void
        trace(path, data.bytesAvailable);
        // I'll let you write the code to save the data to a file path, based on the URL.
    You could also create a class that includes the event handler function and includes the code for loading the data. Then create a new instance of that class for each URL.

  • Copy a linux OS and files from one device and run them on another

    VM or physical?

    I have a device running a linux os and I want to copy its OS and files and then run them on a custom built machine. Is this possible and how would I go about doing it remotely say with FTP?
    This topic first appeared in the Spiceworks Community

  • HowTo read file from app. server and store it in binary format (SDOKCNTBIN)

    Hi
    I need to upload Documents to Document Repository by using to function module RSOD_DOC_MAST_CHANGE.
    My question is: How can I fill the "parameter" i_t_file_content_binary from a file which is stored on an application server.
    br, michael

    Hi
    I need to upload Documents to Document Repository by using to function module RSOD_DOC_MAST_CHANGE.
    My question is: How can I fill the "parameter" i_t_file_content_binary from a file which is stored on an application server.
    br, michael

  • How do i superimpos​e different charts from different sequences and get them to show up while i am taking data

    I have six different frames in a sequence and I have a Build XY Graph express icon in each frame.  I want to display only one graph on the front panel, and want the data to superimpose when I go through each frame of the sequence.  I want the graph to update while I am taking data.

    Here is an example in 8.2 of how I would do it, this method may have performance issues with large data sets.
    Andrew Alford
    Production Test Engineering Technologist
    Sustainable Energy Technologies
    www.sustainableenergy.com
    Attachments:
    Superimpose XY Example.vi ‏37 KB

Maybe you are looking for