Run script in a loop inside sqlplus

Hello all,
Is there a way to run a script that we can run from windows command prompt inside sqlplus to run in a loop???
for example on unix i can do something like
for i in 1..10
do
ls -ltr
ps -ef|grep pmon
sleep 5
done
so can i do something similar inside of sqlplus ??
lets say have a script called @active_session
and now i am inside of sqlplus, but cant i run it in a loop ?? like sleep 5 sec and run @active_session and then sleep 5 sec and run @active_session ??
i hope i have asked the question clearly....

Hi,
user8363520 wrote:
Hello all,
Is there a way to run a script that we can run from windows command prompt inside sqlplus to run in a loop???
for example on unix i can do something like
for i in 1..10
do
ls -ltr
ps -ef|grep pmon
sleep 5
done
so can i do something similar inside of sqlplus ??Your best bet might be to do it at the OS level, the way you're familiar with.
For example:
for i in 1..10
do
sqlplus  username/password@database @active_session
sleep 5
doneI'm not sure about the unix syntax.
Make sure active_session.sql ends with a QUIT or EXIT statement.
lets say have a script called @active_session
and now i am inside of sqlplus, but cant i run it in a loop ?? like sleep 5 sec and run @active_session and then sleep 5 sec and run @active_session ??SQL*Plus wan't designed for this kind of thing. In particular, there is no reall loop mechanism built into SQL*Plus. You can do loops in SQL*Plus, but it's not pretty. See {message:id=4367027}
Depending on what's in your script, you may want to do the whole job in PL/SQL, whcih does have loops.

Similar Messages

  • Run script in endless loop

    This seems to be asked from time to time and I haven't seen a viable solution (so it probably doesnt exist)
    I have a script I want to run forever on a dedicated box.  I basically want ae to read through a directory every minute or so looking for a certain file.
    If I just keep looping the function AE quickly crashes.  I tried putting $.sleep(10000) at the end, which didn't crash as quickly, but eventually it did too.
    Is there any way to run a script in an endless loop (and why doesnt setInterval work as it is part of the javacsript language)
    Mike Cardeiro
    Editor/Animator/Compositor                
    D4 Creative Group - Philadelphia, PA   
    http://www.michaelcardeiro.com/resume/
    http://www.youtube.com/user/mcardeiro

    got it to work using app.scheduleTask("main()", 20000, true);
    seems to work perfectly (much better than $.sleep...I thought I had read that scheduleTask() doesnt work in ae.  It seems like exactly what I needed.
    Mike Cardeiro
    Editor/Animator/Compositor                
    D4 Creative Group - Philadelphia, PA   
    http://www.michaelcardeiro.com/resume/
    http://www.youtube.com/user/mcardeiro

  • Event controll: How to stop a running while loop inside a event structure

    Hello,
    I have some problems with controlling a while loop inside a event structure (see attached VI).
    I habe 3 buttons ("Start Measurement, Stop Measurement, Quit Program"). When a measurement is running, it should be possible to stop the measurement by clicking on "Stop Measurement", but this does not work.
    Has anyone an idea?
    Thanks a lot and best regards,
    Michael
    Message Edited by MichaGue_01 on 04-23-2010 04:37 AM
    Solved!
    Go to Solution.
    Attachments:
    Event_Controll.vi ‏27 KB

    Hello,
    Try not to use while loops inside a Event structure.
    My approach is using two While loops (one will have only the Event structure).
    I had to use to Flag buttons that make it a bit more complicated but i am sure somebody will come up with a better idea, or you might want to have a think about it yourself.
    Have a look on the modified version on the attachment.
    Once you are happy how it works then you can Hide the 2 flag buttons from the Front Pannel by going to Block diagram right-click the indicators and choose option "Hide Indicators/Controls"
    I did it in LV 8.6 so i hope you can open it on your PC if not i can downgrade it.
    If you have any problem let us know.
    Regards
    Dimitrios
    Test Systems Computing Engineer
    Cummins Turbo-Technologies
    Attachments:
    Event_Controll[1]_modified.vi ‏18 KB

  • Running @Script.sql from inside C#

    I'm trying to include a script file as part of a deployment. I'm able to connect to my Oracle XE database in code and run stored procedures as well as text commands. My deployment will copy a script file into an install directory for later use. When the user activates history recording, I want to run this script file.
    I can run the script manually...@"C:\Program Files\History Setup\TestScript.sql"...without issue. Works just fine.
    Currently I recieve an invalid sql command error. At the moment I'm trying:
    Command.Connection = myconnection;
    Command.CommandText = @"@""C:\Program Files\History Setup\TestScript.sql""";
    Command.CommandType = CommandType.Text;
    try
    Connection.Open();
    Command.ExecuteNonQuerry;
    catch (Exception ex)
    error handling
    If anyone has advice for running script files from inside C#, it would be appreciated.

    The other Dennis is correct. You must cleanup the text.
    This should give you a start. I have had good results using the forward slash as a delimiter.
    r,
    dennis
    byte[] ba = GetFileContent("SomeFileName");
    string All_My_Statements = Encoding.UTF8.GetString(ba);
    ExecutScript(NetConnectionString, All_My_Statements);
            public void ExecuteScript(string _connectstring, string _final_statements)
                   string[] cmd_seq = _final_statements.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < cmd_seq.Length; i++)
                    string act_cmd = cmd_seq;
    string tmp = actcmd.Replace("\r\n", "");
    act_cmd = _tmp;
    if (act_cmd.Length > 2)
    try
    int r = ExecuteTextNonQuery(_connectstring, act_cmd);
    if (r == 1) // success
    LogThis("\tSuccess:" + act_cmd);
    else
    LogThis("\tExecuted:" + act_cmd);
    catch (OracleException) { LogThis("\tException:" + act_cmd); }
    catch (System.Exception) { LogThis("\tException:" + act_cmd); }
    public static byte[] GetFileContent(string f)
    byte[] ba = null;
    try
    System.IO.FileStream fs = new FileStream(f, FileMode.Open);
    System.IO.BinaryReader br = new BinaryReader(fs);
    ba = br.ReadBytes((int)fs.Length);
    br.Close();
    fs.Close();
    catch (System.Exception) { };
    return ba;
    public static int ExecuteTextNonQuery(string connectionString, string exec)
    int rtn_int = -1;
    using (OracleConnection oraconn = new OracleConnection(connectionString))
    string execcmd = exec;
    try
    _oraconn.Open();
    using (OracleCommand cmd = new OracleCommand(_execcmd, _oraconn))
    cmd.CommandType = CommandType.Text;
    rtn_int = cmd.ExecuteNonQuery();
    catch (OracleException _oraEx)
    throw (_oraEx); // Actually rethrow
    catch (System.Exception _sysEx)
    throw (_sysEx); // Actually rethrow
    finally
    if (_oraconn.State == ConnectionState.Broken || _oraconn.State == ConnectionState.Open)
    _oraconn.Close();
    } //using _conn
    return rtn_int;

  • Run for loop inside event node

    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    Thanks & Regards,
    Harish. G.

    harishg92 wrote:
    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    You're implementing a For loop inside an event structure? (I don't know of any event "node" in which you can run a For loop)
    If so, that's a bad idea because LabVIEW won't be able to process any events while waiting for your For loop to get done, which might be why its crashing.
    There are tricks to accomplishing what you're trying to do without putting any for loops inside event structure. See what I have  attached and if it helps. "N" is number of times you run your For loop, timeout is whatever delay you want in each loop. This can be done in many ways without adding delays in events, another way could be to fire a separate subVI using Asynchronous call (without waiting for the VI to finish) during those delays, just make sure that such subVI finishes processing within your allocated time (that's how I'd ideally implement things). That method is better because you're doing minimal work inside events structure while using wait period wisely in a separate/parallel process.
    I hope that I understood you correctly and did not go off on a tangent.
    -BTC
    New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI
    Attachments:
    ForLoop inside Event Structure.vi ‏11 KB

  • Thanks for your help. But couldn't run script files

    Hi Saar:
    Thanks for your advise on creating shared folders on VM ware Red hat Oracle to run script files stored on my local F: drive.
    However I got this error when I tried to load and run a script file "Bookscript.sql" in i*sqlplus:
    SP2-0869: invalid file content.
    Path to file is :
    /mnt/hgfs/OracleVM_1/OracleVM_1/9iSQL/JustLeeDatabase/Bookscript.sql.
    Why is this so what can I do to run it?.
    I*SQLPLUS error messages recommends to make sure the browser has "SQL" MIME type.
    Action: Make sure that the script is in a text file and the MIME type settings needed by the browser to recognize the file are set correctly. Typically if you are loading a file with the extension .SQL, make sure the browser has a "SQL" MIME type.
    How do I do that?
    Thanks

    I assume that you are trying with the browser inside the VM, mozilla 1.4 I think. Please try with IE 6 or Netscape 7.2 from the Windows host access the same exact URL it will talk to the linux box, I trust the script will load and this is an issue with how mozilla 1.4 loads files, it might be fixed in later versions of mozilla. If problem still exists, copy the file to /tmp on the linux box and repeat test.
    let us know. In the future please reuse your existing thread until the issue is resolved.
    good luck,
    Saar.

  • How do I increment a variable at the end of a loop to run it through the loop again?

    I'm new to LabVIEW programming and I'm trying to write a small program that just receives a lower and upper limit, and whether the user wants to increment or decrement the number. I can't figure out how to increment the number after the simple calculations have been done and to run through the loop again with the incremented number. Right now I'm using a while loop inside of a case structure where true decrements and false increments.

    Here are a few possibilities.
    Message Edited by altenbach on 12-05-2008 03:25 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    fractionaIncrement.png ‏8 KB

  • Running scripts in Aperture

    Aperture appears to have the facility to run scripts during the import stage (it's called 'Action' in the import pop up menu), but I'm having problems with it.
    I have successfully run the script below, and have exported the subsequent metadata to the master, which is my aim.
    But I cannot get the script run via this 'Actions' facility during import, even importing into a second library after the 'Object Name' field (called 'Title' by Aperture) has been created in the file and contains a 'space'.
    Can anyone show me what I am doing wrong?
    I found the script at: How can I set the Object Name to the file name on import?
    The post reads:
    AppleScript to the rescue!
    1. Copy the following text into Script Editor:
    tell application "Aperture"
    set selectedImages to the selection
    set tName to name of item 1 of selectedImages
    repeat with i from 1 to number of items in selectedImages
    set this_item to item i of selectedImages
    set tName to name of this_item
    set value of IPTC tag "ObjectName" of this_item to tName
    end repeat
    end tell
    2. Save the script in a sensible place, such as ~/Library/Scripts/Aperture Scripts so that it will turn up in the Script Menu (if it's enabled).
    3. Select a bunch of images in Aperture.
    4. IMPORTANT! You must use Batch Change to put a value into the Object Name tag (such as " "), until you do so the tag doesn't exist for those images and therefore cannot be altered.
    5. Run the AppleScript, it should loop through all the selected versions and put the version name into the Object Name tag.
    Note - the Master File Name isn't accessible via AppleScript, only the Version Name.
    Ian
    P.S. As with all such scripts, test it on a small number of 'spare' versions before doing anything drastic...
    Help!

    I haven't. Have you tried making a droplet to run at the end of the LR export?

  • Execute a sheel script (that is login to sqlplus and do some query) by ssh

    I have two unix box. lets say...box1's ip is : a.b.c.d and box2's ip is : w.x.y.z
    We have shared the public key by "ssh-keygen -t rsa" in both the box so that it will not prompt password for ssh connection.
    Now, in the 2nd box I wrote a shell script (test.sh) like below..
    #!/usr/bin/sh
    ORACLE_HOME=/u01/app/oracle/product/11.1/client_1
    echo "Hi..." > /popdb/batchApp/scripts/a.txt_1
    $ORACLE_HOME/bin/sqlplus -s user/pass@sid <<EOF > /popdb/batchApp/scripts/a.txt
    select * from dual;
    EOF
    now from the box1, I want to execute the tesh.sh by ssh..run the command below...
    ssh [email protected] exec /full_path/test.sh
    we got an error message like below...
    Error 6 initializing SQL*Plus
    Message file sp1<lang>.msb not found
    SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
    and also found that a.txt_1 is generated with the desired output but a.txt is generated as 0 byte file in box2.
    Can anybody give some light on it....thanks..

    Hi;
    Please see:
    SP2-0750 Error when Trying to Invoke SQLPlus Executable [ID 742952.1]
    Login SQL*Plus Encountered SP2-0667 SP2-0750 even $ORACLE_HOME Has Set in Profile [ID 1075034.1]
    "Error 6 initializing SQL*Plus : Message file sp1.msb not found" when invoking SQL*Plus Instant Client [ID 368277.1]
    Regard
    Helios

  • Simulation loop inside subVI inside a simulation loop

    First of all, let me just say, I've got to hand in my work in 24 hours so please any help will be appreciated.
    I've got a simulation loop inside a subVI inside a simulation loop. If I give the inner loop enough time to run, i.e make its duration smaller than the time step of the outer simulation loop. Shouldn't everything run smoothly? Or is this just a no-no with labview?
    Thank you

    Hi VicMackie,
    This help file on the properties of the Simulation Loop is likely to help you out.
    I believe from you posts that you're wanting the loop to run every second.
    Therefore you want to check "Synchronize loop to timing source" and set your 1kHz clock or set a 1kHz <reset> so that it'll reset on every invocation of the loop. From your post, I understand that you've already done this.
    As the period is in milliseconds, for a period of a second you'd want to set your period to 1000 milliseconds, which is the default (1000).
    I'd recommend leaving the step size at the default for now and just modifying the Timing Parameters tab to confirm whether the loop will execute every second if you set the period to 1000.
    Best wishes,
    Tori
    Student

  • LOOP inside FORALL in bulk binding

    Can I use a loop inside forall in bulk bind updates?
    as I understand, forall statement strictly loops through the length of the bulk limit size for the immediately following statement only.
    I am attempting to use a loop there to update more than one table.
    cursor c is select id from temp where dt_date > sysdate-30;
    BEGIN
    loop
    fetch c into v_id;
    limit 1000;
    forall i in 1..v_id.count
    UPDATE table_one set new_id = v_id(i);
    exit when C%NOTFOUND;
    end loop;
    end;
    I want to update another table table_two also immediately after updating table_one like this:
    forall i in 1..v_id.count
    UPDATE table_one set new_id = v_id(i);
    BEGIN select nvl(code,'N/A') into v_code from T_CODES where ID_NO = v_id(i); EXCEPTION WHEN NO_DATA_FOUND v_code='N/A'; END;
    UPDATE table_two set new_code =v_code;
    exit when C% not found.
    This is not working and when I run it, I get an error saying encountered BEGIN when one of the following is expected.
    I got around this by having another FOR loop just to set up the values in another array variable and using that value in another second forall loop to update table_two.
    Is there any way to do this multiple table udpates in bulkbinding under one forall loop that would enable to do some derivation/calculation if needed among variables [not array variables, regular datatype variables].
    Can we have like
    forall j in 1.. v_id.count
    LOOP
    update table 1;
    derive values for updating table 2;
    update table 2;
    END LOOP;
    Thank You.

    Well, without questioning reasions why do you want this, you are confusing bulk select and forall. You need:
    begin
        loop
          fetch c bulk collect into v_id limit 1000;
          exit when v_id.count = 0;
          forall i in 1..v_id.count
            UPDATE table_one set new_id = v_id(i);
        end loop;
    end;
    /SY.

  • Error -50103 occured with timed loop inside a while loop

    Hello everyone,
    i wrote an application to sample analog voltage from  DAQ6024E card (see the attachments).
    I have a big while loop in the VI because a I want to add some other functions later.
    In the "WHILE_Cont Acq&Graph Voltage-Int Clk.vi" I use a while loop inside the big while loop to read the samples. It's working properly.
    but when I use a timed loop inside the big while loop (see "TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi"), I get an error -50103 from the timed loop.  It seems that the first cycle is ok, but after the first cycle the error occurs.
    I don't know what happens with the timed loop, anyone can help me? what does the error -50103 mean? thanks a lot!
    PS: I am using LabVIEW 8.0
    Message Edited by molo511 on 10-22-2006 05:21 AM
    Message Edited by molo511 on 10-22-2006 05:23 AM
    Attachments:
    TIMED_LOOP_Cont Acq&Graph Voltage-Int Clk.vi ‏143 KB
    WHILE_Cont Acq&Graph Voltage-Int Clk.vi ‏75 KB

    hi molo511,
    I tested your program but only with simulated devices. I had to delete the wire to the timing, so that the timed while loop runs with 1kHz. Did you already try this? Because this works on my PC.
    I also found a link in our database that might be interesting for you.
    http://digital.ni.com/public.nsf/websearch/04BEDD9E9E91ED3486256D180048116D?OpenDocument
    Greets
    Philipp N.
    NI Application Engineer

  • While loop inside a timed loop

    Hi everybody!
       I'm using:
           - LV 7.1 + RealTime;
           - compactFieldpoint;
       I've noticed a strange behaviour, when I put a while loop inside a timed loop.  Let's fix timed loop with these settings:
           - 1 KHz clock
           - 1 ms period (yes, I know it's short....)
           - offset 0 ms
           - Phase 0
           - Discard missed period (ON) and MAintain original Phase (ON);
           - Timeout: -1.
       If inside this loo, I put a traditional while loop, waiting (say) for an event to occur, and if this event does not arrive, my cFP-2020 hangs! I mean, it becomes unreachable for the debugger, and, more, if I run a ping to it's address, after some cycles it becomes unreachable also from ping!
       Clearly, this code statement lock the fieldPoint, because if I remove the inner while loop all works.
      I know that with 1 ms period, timed loop always finishes late, but I set to discard missed period and timeout to -1. 
       It seems to me that sometimes Timed Loop add heavi overhead to programs, I'm turning to all while loop based tasks, even if my application has to be real-time!
       Advices welcomed! Have a nice day!
    graziano
    Solved!
    Go to Solution.

    I think the issue here is that putting your while loop inside a Timed Loop increases the priority for that task. Timed Loops can have dynamic priorities set over eachother, but they all run between Above Normal and Time Critical priority. My guess is that the debugger and built-in TCP functions run at Above Normal priority or less. This means your cFP isn't hanging, it's doing what it thinks is best. It's trying to finish this task before handling any lower-priority tasks.
    The suggestion to put a Wait function in your loop is an OK one. Keep in mind that you can actually set your wait time to zero instead of one and get the same positive benefit of handling other tasks. I would also suggest that you might look into waiting for this event in a lower priority (non-Timed) loop, and then transmit the appropriate data to your Timed Loop using an RT-FIFO or something. That might give you better handling. Just a thought....
    Jarrod S.
    National Instruments

  • Simple example - Break FOR loop inside an event structure based on Front panel event change.

    I am running a for loop inside a state machine architecture that contains a FOR loop. How can I break this For loop based on Event change in front panel ??
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.vi ‏19 KB
    Case inside Event.ctl ‏6 KB
    Case inside Event 2.ctl ‏6 KB

    Okay. Accpeting that the design is not favorable and not advantageous when my program expands. I have begin to follow producer/consumer programming architecture.
    Please find the attached program which is a simple producer consumer with event structure. I wonder how could I stop looping around the producer and consumer loops over and over again. I am pretty sure that this ENQUEUE ELEMENT loops back to the consumer loop and starts from begining.
    I hope my first program in PC architecture with State machine and Event structure is correct. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.3-ProducerConsumer Event.vi ‏25 KB
    Case inside Event.ctl ‏6 KB

  • Running script

    Well here is another problem I need help with. When I am on the webpage www.geocaching.com, and click on a
    geocache link, my BB will request, load, running script, loading, requesting, running script all in a endless cycle.
    The page will never load, just cycles as described. What do I need to change on my BB Tour?
    You all have been very helpfull with my questions. Once again, thanks in advance for your help.

    Do you have an example of a geocache link?
    Okay, I tried the Hide & Seek A Cache link, and with JavaScript enabled, I ran in the continous loop problem you were experiencing. I turned off JavaScript and was able to access the Hide & Seek A Cache page.
    Interestingly enough, though I have "Prompt to enable JavaScript" enabled, I never did receive a request to enable JavaScript. I checked the source for the Hide & Seek A Cache page with Firefox on my desktop computer and it definitely has references to JavaScript. So JavaScript handling by the BB Browser is sketchy at best. I wish there was a way to set JavaScrip on a per page or per website basis.
    Message Edited by mousky on 09-13-2009 09:54 PM

Maybe you are looking for

  • G4 flat panel won't boot

    when booting it just stalls on the loading screen and stays with the blue bar forever! I tried disk repair, it said there was no problem....any help? mc

  • Photo Albums Take FOREVER to View in iWeb and Internet

    I have been waiting for the past 10 minutes for iWeb to bring up my family photo album for me to add photos. This has been getting worse and worse as I post more family albums to our site. It is now 15 minutes since I tried to open-edit-add an album

  • UltraWide Resolution Possible on MBA 2013?

    I ordered a Mini DisplayPort to HDMI cable in hopes of using my LG 29EA93 monitor. To my dismay, the MacBook Air 2013 refuses to output to UltraWide 2560x1080 resolution. Am I doing something wrong? Any workarounds? Or am I just stuck with using the

  • Is there any problems in iphone 5 wifi? others connecting but mine is not.. sometimes depends on distance!

    is there any problems in iphone 5 wifi? others connecting but mine is not.. sometimes depends on distance! help pls

  • Warning message from nowhere.

    After months of editing in Adobe Camera Raw with no problems, I go to edit this morning and this lovely warning message greets me.  Camera Raw editing is not enabled.   then this below... Camera Raw editing requires that a qualifying product has been