Loop on wait or sleep in oracle

Hi all
I had to check for a FILE1 on the Unix and then if the FILE1( we call it as Trigger file for the process) then it look for the Data file and theni i had to utl_file.fcopy.
If the Trigger file is not there it has to look for file after 5 sec and this should continue for 5 times.
Even the Trigger file is not found (some cases it is optional) then it should copy the the Data file.
declare
l_Trig_file   BOOLEAN := FALSE;
l_Data_file  BOOLEAN := FALSE;
File_Name  varchar2(30) :='Work_file';
Input_Dir varchar2(30) :='INPUT_DIR';
Work_Dir varchar2(30) :='WORK_DIR';
begin
    IF NOT NVL(l_Trig_file   ,FALSE) THEN
   --here i had to wait for 5 seconds and also i had to loop for 5 times
      ELSIF NOT NVL(l_Data_file  ,FALSE) THEN
  dbms_output.put_line('data file not found');
      ELSE
         dbms_output.put_line( 'Copying the '||l_Data_file  ||'from source to destination' );
      UTL_FILE.fcopy (src_location    => Input_Dir ,
                             src_filename    => l_Data_file  ,
                            dest_location   => Work_Dir,
                           dest_filename   => File_Name
      END IF;
      Please help how to make a procedure to wait for 5 sec and make it loop for 5 time...
Thanks
Rede

Have a look at DBMS_LOCK.SLEEP procedure.

Similar Messages

  • Difference between wait() and sleep()

    hi
    can any one tell me what is the difference between wait() and sleep().
    thanks in advance.

    Mahaboob,
    This question has been asked before; however, I will give you a real life example.
    Imagine you are in a super market and you go to the till to pay by your card, then behind you there are 10 people waiting in queue. You card does not work since you have not supplied the right pin code; there are two option
    1- Sleep
    2- Wait
    1- If you sleep you will lock the till for your self and try to figure out the pin number while the queue behind you increase on the resource (till)
    so you are engaging the till and wasting its time and wasting the till machine resource (CPU)
    2- you are polite, you move aside and wait so so that others can use the resource (till) until somebody in the queue finishes ( a good person) and give you a shout to tell you come in to the till to process your payment; you wake up and enter the pin number and go out from the super market.
    Now when you sleep, the current thread locks the resource so no body can use it and wast the CPU time
    while wait make the current thread release the lock on the object and does not ( this thread) actually wast the CPU time
    There are much more explanantion, try to search this forum.
    Regards,
    Alan Mehio
    London,UK

  • Using wait or sleep without a thread

    Is there any method to do the equivalent of a wait or sleep without using threads?

    You have a single-threaded application executing, and
    you want to pause it at a given location for a given
    period of time. If you call sleep, you give up
    execution, which you don't want to do.What do you mean by not wanting to give "up execution"? It is the scheduler of your OS that decides when your program executes or not. Your code snippet does nothing but burn processor time (incidently pretending to the scheduler that it actually has something useful to do) which could be well used by some other process running on the computer. Use Thread.sleep instead, thats what it is there for. If you want to somehow affect the amount of processor time that the scheduler allocates to your process you will be better served by increasing its priority.
    having my skill and/or intelligence mocked Well, I have certainly not mocked your skill nor your intelligence, god knows that I have on occasion presented poor solutions in this and other forums, but lets not dwell on that...

  • Wait() vs sleep()

    This is a purely general question, I was wondering which is better to use: sleep() or wait()?

    Use sleep() if you just want to wait for some time,
    for example if you want to wait before you retry to
    create a socket connection when the first try failed.
    This is wrong. Never use sleep when you are using synchronization, it could cause deadlocks. Instead, use wait as wait will release all your locks and thus reduce the chance of deadlock. Remember that your thread may be holding locks that you are unaware of so it's best to wait (not sleep).
    Use wait() if you want to synchronize multiple
    threads, for examplw when one thread has to wait for
    the resutl of another thread. >
    So fi you have only one thread ( and i assume that
    have you never written a multithreaded app) just use
    sleep() adn forget wait(). They might look similar but
    serve quite different purposes.
    Java is multithreaded by nature, it's impossible to write a non-multithreaded application in java as there are at least a few threads ( finalizer thread, GC thread, your main thread). And any non-trivial java program will have at least 2 threads. Any java application that uses swing has at least 7 threads. So you must expect that your code will be run in multiple threads and thus sleep is not a good choice.
    I don't think that using sleep should be recomended because it doesn't release locks.

  • Topic about wait(),join(),sleep() and yield()

    Hi there,
    I'm headache with the implementation of wait()��join()�� sleep() yield(). Can anybody tell me:
    1. what's the difference between wait() and join(), I can't see it.
    2. As I know if thread A waits on thread B then A will release the lock. How about join, or slepp, or yield?
    3. Why use notify()? As I see if thread A waits on thread B, when B completed without calling notify(), the A will continue its job!!
    thanks thanks thanks

    1. Object.wait() will make a thread wait until Object.notify() is called on the object. Thread.join() will make the running thread to wait until the thread object finish to execute.
    2. .wait() does not wait on thread, it wait on objects. .sleep(long timeout) is about the same as .wait(long timeout), except that it need to be awaken with a .interrupt, not .notify. Also you cannot awaken more than one thread with a .interrupt, while a call to .notifyAll() will awaken all threads waiting on that object. .yield() suspend the current thread only to give a chance to others thread to execute and the initial thread will continue ot execute only a hort time after the .yield().
    3. See #1, #2 and think a bit.
    Regards

  • Database queries - is there a wait or sleep functionality?

    Hello everyone,
    I have recently encountered a problem where a database collector I made
    just stops querying after a while and needs restarting in the ESM for it
    to work again. In other databases (I am querying Oracle btw), this does
    not happen and in some others it does. So I am basically thinking that
    some databases are configured to limit the amount of querying or force
    an exit on error.
    What I have noticed, is that in my Oracle environment (no fancy
    configurations, all very permissive) I get alot of ORA-0100 errors
    indicating that there are too many open cursors. This happens when the
    last row in the database has been reached and the errors stop being
    shown in Active Views only after some data is inserted in database and
    collector resumes normally the task of collecting data until no more
    records are available and once more errors appear in Active Views.
    I altered the amount of allowed open cursors and incremented from 300
    to 500. Still, I keep getting errors (like every 20 seconds). I want to
    minimize these amount of errors and hopefully solve my original problem
    of having to manually restart the collector in some customer
    environments. I came up with the following snippet (bottom of message),
    but can't seem to find a function for having the collector sleep or
    wait. I tried Thread.sleep() (From Java) and setTimeout() (From
    Javascript) but both raise errors since they are undefined methods for
    the collector.
    The Sentinel API makes reference to "queryDelay" and "queryScheduled"
    flags which are supposedly defined in sqlquery.js. I cannot find any
    reference in the code to these flags and I am not even sure of how to
    implement them ( if(!queryDelay) { conn.send(DBQUERY) } ?????? ).
    How can I use these flags in the code to help me reduce the number of
    queries being thrown when there is no data? Or will I have to hack my
    own sleep or wait function? I appreciate any assistance!
    snippet of code I want to implement:
    Code:
    Connector.prototype.sendQuery = function(){
    if (rec.CONNECTION_STATUS == "NEED-QUERY") {
    if (instance.CONFIG.myCounter >= 3) {
    //HERE INSERT A SLEEP OR TIMEOUT FUNCTION
    instance.CONFIG.myCounter = 0;
    } else {
    conn.send(instance.CONFIG.DBQuery);
    //instanced in initialization function. Resets to zero when query is successful.
    instance.CONFIG.myCounter = instance.CONFIG.myCounter + 1;
    return true
    Jean-Paul_GM
    Jean-Paul_GM's Profile: http://forums.novell.com/member.php?userid=12809
    View this thread: http://forums.novell.com/showthread.php?t=445597

    I experience the same problem with my custom collector.
    But the beta connector is not there anymore.
    Can you please provide the connector so that I can test if it solves my
    problem.
    Thanks.
    ab;2141610 Wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > If this works I'd like you to open an SR for it so we can link it to
    > the
    > bug, but in the meantime:
    >
    > 508a0b25988c98a152ff5889edb41882 jdbc2011.1r1beta2.tar.gz
    >
    > ftp://ftp.novell.com/outgoing/jdbc2011.1r1beta2.tar.gz
    >
    > This is a beta and has not been fully ZA'd but seems to resolve your
    > issue for another customer. If it does please be sure to at least
    > post
    > back here if not open an SR (which will be credited to you as this is
    > Bug# 700669 most likely).
    >
    > Good luck.
    >
    > - --
    > Want to yell at me in person?
    > Come to BrainShare 2011 in October: http://tinyurl.com/brainshare2011
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v2.0.15 (GNU/Linux)
    > Comment: Using GnuPG with Mozilla - 'Enigmail: A simple interface for
    > OpenPGP email security' (http://enigmail.mozdev.org/)
    >
    > iQIcBAEBAgAGBQJOge8eAAoJEF+XTK08PnB5ORoQAJcX9moFMh AfcpLSaIVhFLFj
    > ZcmfRjJs4IyT+xatk9wp1S/+eq81AMuyxsoGK/RQfwkKQtzJWiUtQAulCVPjFJZP
    > 3Hy2yBAJYUe5Rm3kedfeFlW3vFIV7wecl4el1UPRs4Q9DBUuBa XqP1KHgDrx4iue
    > ECEph0scQmlp+SxeBUZKfVwWY9NRKio3kxRPJ3QmzPPQ8euP6Z RYcDtwfJq4rrQf
    > z8GcV4ylHZxgIqGXI2pV47zBPPuU/lppytAnyaZSQm5ODs1ndi8f7i/MLPZ4SGI4
    > rkjUURVmkYim7UOA6QLxYUxUJF5SDGyjyJS2h2wGb5caBACMsA XDeySZ6ARMxtqs
    > 9mzb+Zj3VC4+54yVFAXDUq7mzMa5NE0WqxTR9lNoBMnnLmjwyk b9YDfmDUFZCpmT
    > QtWM68bgqtl/p1kcjQq0yAsTVTniGsOynpfTvZjsi4Y4hDCC9ktf8HP7aqu+Tb Nn
    > ehVYbG8zM8muUfiAEMTfjm7X07DK5uTTduNnnCbysnvNcCdRlu SEinfZsDRiihEt
    > gdoYFRYicy3SrJTL769TlzlKd3LU8ICqy8fnHLVeJjPanWxRCQ ISFUuhb5NI1h8Q
    > unVZAzHzcpJCidMLm/cOpCVbyPeaTeG3HbQzNOqwKyd4FFfHvzIBh0JVzO2uCScf
    > nvoosfhMydAkj0sgWXvH
    > =AVMR
    > -----END PGP SIGNATURE-----
    hkalyoncu
    hkalyoncu's Profile: http://forums.novell.com/member.php?userid=63527
    View this thread: http://forums.novell.com/showthread.php?t=445597

  • Wait or sleep?

    Hi,
    I am at University doing Java. My new assignment is multithreading in a Windows Application.
    So,
    I have created 2 threads (one with just a string and the other making a sound (wav file)).
    My problem now is ...
    I want the window to open first, then for the words to show up on the window, AND THEN the sound. Now I want the sound to be done in 3 consecutive times.
    In other words:
    1st: fT
    2nd: s1T
    3rd: s2T
    4th: s3T
    Basically here is what I did:
    import java.awt.*;
    import java.awt.event.*;
    public class WindowsAppli extends Frame {
        TextArea outArea = new TextArea("Incoming call ...\n");
         T1 firstT = new T1();
         T2 second1T = new T2();
        T2 second2T = new T2();
        T2 second3T = new T2();
            public WindowsAppli ()
           add(outArea);
           setLayout(new FlowLayout(FlowLayout.CENTER, 10, 15));
           Thread fT = new Thread(firstT);
           fT.start();
           try
              Thread.currentThread().sleep(10000);
           catch (InterruptedException e)
          outArea.append(firstT.res);
          Thread s1T = new Thread(second1T);
          Thread s2T = new Thread(second2T);
          Thread s3T = new Thread(second3T);
          s1T.start();
          s2T.start();
          s3T.start();
        public static void main(String[] args)
            Frame f = new WindowsAppli();
             f.setTitle("Windows Application");
              f.setSize(600,400);
              f.setVisible(true);
             f.addWindowListener (new WindowAdapter ()
                public void windowClosing(WindowEvent e)
                     System.exit(0);
    }Any help please?

    If you want to wait for some even to occur, use wait, and a corresponding notifyAll(), or the higher level scheduling tools in java.util.concurrent.
    If you want to pause for a fixed amount of time, use sleep, although if you're doing that in a loop, you may want java.util.Timer and TimerTask.

  • How can i restore an iPhone 5 from Recovery Mode loop with broken lock/sleep button?

    Hello,
    I just tried to delete all my data from my iPhone 5 32gb iOS 7.0.4 (with not working lock/sleep button) to install iOS 8.0.2 and after that the loading bar appeared on the screen. When it finished, the iPhone rebooted and went into Recovery Mode loop and it is still in it (after 3 hours +). Also, iTunes doesn't detect the iPhone at all.
    I hope, the solution will be found, thanks.

    Any suggestions?

  • Running a loop without waiting on all readings

    Hello,
    I have been struggling to create a vi that does exactly what I want.  I want to take multiple measurements from multiple sources at the same time with a time stamp.  I have been getting all of the measurements accurately.  My problem is that I need a very high sample rate for my data, and the instrument connected to my VISA serial read only samples at a rate of one measurement per 1.6 seconds.  This is acceptable for this measurement, but my other measurements need to have hundreds of readings per second.  However, it appears that my loop will only iterate once every 1.6 seconds, which I assume means that it is waiting for the next reading from my VISA device.  Is there a way to tell Labview to check for a reading or obtain a new reading only when one is available, instead of holding all of the other readings to a 1.6 second sample rate?
    The vi I am working with is attached.  I originally used a WHILE loop but in an effort to speed up the iterations I switched to a TIMED loop.  This did not help.  I need all of the measurements to be sampled as fast as possible.
    Thanks
    Attachments:
    ScratchVIc.vi ‏175 KB

    Separate your code and use multiple loops. There is nothing wrong about using multiple loops. You want to avoid splitting your DAQ collection across multiple loops. But separating other types of processing is how you can improve performance. Have one loop do nothing but collect the data. This loop would post that data to a queue for further processing. You could also separate logging the data into it's own loop too. Again, data to be logged would be posted to a queue for processing. Writing data to a file in the same loop as you are collecting the data will decrease your performance. File access is slow.
    Also, learn how to use data flow and avoid all of the stacked sequence structures. Most of the stuff in teh sequence structures already has data flow which will control the execution order. Deep stacked sequences are difficult to maintain and modify. You should also take some time to learn about state machines.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Difference betn  wait() and sleep() method of a thread

    Can anyone briefly differentiate between the sleep() and wait() method of a thread.

    [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long)]sleep
    [url http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#wait()]wait

  • Hypothesis testing about While Loop with Wait MS

    I'm posting VIs here for users to download as part of another conversation going on here.  Please ignore these VIs unless you've read my post that other thread and decided to test the theory yourself.
    The attached are for LabVIEW 2009.
    Save the .mnu file over your existing file at
              C:\Program Files\National Instruments\LabVIEW 2009\menus\default\plat\structs.mnu
    (make a backup copy first)
    (also, the .mnu file has been given a .txt extension so that I can post it to the forums... remove that .txt extension when saving it)
    and save the VI as
              C:\Program Files\National Instruments\LabVIEW 2009\vi.lib\Utility\WhileLoopWithWait.vi
    Attachments:
    WhileLoopWithWait.vi ‏5 KB
    structs.mnu.txt ‏3 KB

    File I/O is not very efficient. I recommend that you do you file logging in a parallel task. Have one task do your data acquision. This task would then pass the data to be logged to the logging task via a queue. That way your file operations do not impact your data acquision. Also, express VIs are not very efficient. You would be better off accessing that directly using the DAQ VIs. The express VIs contain lots of steps that do not need to be done every time you call it such as initializing the device.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Is there a SLEEP command in oracle

    I tried using sleep(5); in one of my PLSQL.
    The database does not recognize the command
    Any body with experience on this

    Hi,
    Another solution is to write a loop to wait for the given seconds. Depends upon the wait time, you could increase the loop counter.
    Thanks.

  • Sleep or wait() / notify()  Which is better IYO

    Consider an app where a central object, like an information server is handed a query and an amount of time will pass before that information is available. For caching, many objects may ask the same question and be waiting on the same answer. Is it better to have the queries do a sleep loop to wait for the response or is it better for the queries to register with the server and call a wait(), then have the server issue a notify to objects that were waiting?
    Thanks for the advice.

    Thank you. I like sleep as well. Although with three little ones that can be a difficulty.
    I am having a difficulty with how to implement the wait notify. Can you tell me if the following is a good / bad / normal / horribly wrong example?
    // sorta code...
    // This class goes to a central location
    // or the network for an answer.  It represents one answer for one query.
    class InfoServerQuery extends Thread{
      volatile boolean isComplete = false;
      volatile String response = null;
      Vector pool = new Vector();
      public synchronized boolean isReady(Object obj){
        if(!isComplete){
          // Add object to answer pool
          pool.add(obj);
          return false;
        }else{
          return true;
      public void run(){
        try{
          // Get the information.......
          response = getInfo();
          // set isComplete
          isComplete = true;
          // notify all that are waiting.
          for(int a = 0; a < pool.size(); a++)
          synchronized(pool.get(a)){pool.get(a).notify();};
        }catch(Exception e){
          throw new RuntimeException();
    // This class asks the questions.
    class QueryClient{
      // instantiated in constructor
      InfoServerQuery q;
      public String getAnswer() throws Exception{
        while(!q.isReady(this)) synchronized(this){wait();};
        return q.response;
    }Thanks for any insights.

  • Sleep / wait function for Business Server Page

    Hi friends of BSP,
    on my BSP I generate at the onload function x iframes for calling BEx 7.x WebTemplates.
    It is a dynamical count of iframes depending on some URL parameters.
    Now, I get the problem, that if the count of iframes is to big, the system can not load all WebTemplates, because they are generated to fast and the system can not handle this amount of processes.
    Is there a possibility to include a wait or sleep function?
    If the answer is "yes", how to implement those functions?
    thanks for any help and support
    kind regards
    Patrick

    Hi Jamie,
    now, we us the JS method window.setTimeout().
    But there are some restrictions.
    In BSP Applications this method works only if the delayed functions is the same function calling the delayed function
    function delayFunction(index)
      var timeout
      timeout = window.setTimeout(function() { delayFunction(i) }, 1000);
    and the delayed called has to be the last step of the function
    (for exmaple there is no possibility to include the setTimeout-function in an IF condition or in any loop).
    Many thanks
    Kind regards
    Patrick

  • How do terminate a wait condition in a loop?

    I have a while loop that uses a Wait.vi to set the timing. When I terminate the loop, it waits for the next iteration of the "wait" to complete. How can I terminate the wait in the middle of an iteration?

    There is no way to stop a wait function. In order to get the behavior you want you need to make your own wait function, that uses the tick count VI and just checks to see if the total time has passed, or if you have asked it to stop.
    Take a look at the attached VI.
    Attachments:
    lv7_Wait_with_Stop.vi ‏21 KB

Maybe you are looking for

  • Is there a way to view old floppy disks running Maverick?

    Is there a way to view old floppy disks when running Maverick?

  • I can no longer repair permissions with Disk Utility, v. 13

    After installing iTunes update 11.1, I can no longer repair permissions with Disk Utility, v. 13. When I attempt to repair Disk Permissions, there appear dozens of items showing that "Permissions differ on "Applications/iTunes.app....", then it says

  • Streaming movie plays perfectly on MAC but not on PC, why?

    I have created a streaming movie and put it online. I have installed the latest version of Quicktimne for PC. The movie streams and plays perfectly on my Mac however it does not stream on my PC. It plays on the PC when it has fully downloaded (in the

  • How to import multiple folders?

    When I want to import a folder with sub folders within it and I drag that into iTunes it does not import the subfolder structure. Is there a way of achieving this without having to import one folder at a time? Kevin

  • ORA-06508 WHEN ALL PACKAGES EXISTS AND ARE "VALID" !!!

    Oracle 8i In a production release, I must change a central package (spec and body), which is used by some other packages. As a result, after the compile, the concerned packages are all marked as invalid. Now, we need to recompile all the invalid pack