<p>What's the best way to do the semantic equivalent of the traditional sleep() system call from within an Informix SPL routine?  In other words, simply "pause" for N seconds (or milliseconds or whatever, but seconds are fine).  I'm looking for a solution that does <em>not</em> involve linking some new (perhaps written by me) C code or other library into the Informix server.  This has to be something I can do purely from SPL.  A solution for IDS 10 or 11 would be fine.</p>

<p>@RET - The "obvious" answer wasn't obvious to me!  I didn't know about the SYSTEM command.  Thank you!  (And yes, I'm the guy you think I am.)</p>

<hr>

<p>Yes, it's for debugging purposes only.  Unfortunately, CURRENT within an SPL will always return the same value, set at the entry to the call:</p>

<blockquote><p><i>"any call to CURRENT from inside the SPL function that an EXECUTE FUNCTION (or EXECUTE PROCEDURE) statement invokes returns the value of the system clock when the SPL function starts."</i></p>

&mdash;<a href="http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqls.doc/sqls1011.htm" rel="nofollow noreferrer">IBM Informix Guide to SQL</a></p></blockquote>

<p>Wrapping CURRENT in its own subroutine does not help.  You do get a different answer on the first call to your wrapper (provided you're using YEAR TO FRACTION(5) or some other type with high enough resolution to show the the difference) but then you get that same value back on every single subsequent call, which ensures that any sort of loop will never terminate.</p>

[{'answer_id': 7240, 'author': 'PW.', 'author_id': 927, 'author_profile': 'https://Stackoverflow.com/users/927', 'pm_score': 0, 'selected': False, 'text': '<p>I assume that you want this "pause" for debugging purposes, otherwise think about it, you\'ll always have some better tasks to do for your server than sleep ...</p>\n\n<p>A suggestion: Maybe you could get CURRENT, add it a few seconds ( let mytimestamp ) then in a while loop select CURRENT while CURRENT &lt;= mytimestamp . I\'ve no informix setup around my desk to try it, so you\'ll have to figure the correct syntax. Again, do not put such a hack on a production server. You\'ve been warned :D</p>\n'}, {'answer_id': 7617, 'author': 'PW.', 'author_id': 927, 'author_profile': 'https://Stackoverflow.com/users/927', 'pm_score': 0, 'selected': False, 'text': "<p>Then you'll have to warp CURRENT in another function that you'll call from the first (but this is a hack on the previous hack ...).</p>\n"}, {'answer_id': 80353, 'author': 'RET', 'author_id': 14750, 'author_profile': 'https://Stackoverflow.com/users/14750', 'pm_score': 3, 'selected': True, 'text': '<p>There must be some good reason you\'re not wanting the obvious answer:\n<code>SYSTEM "sleep 5"</code>. If all you\'re wanting is for the SPL to pause while you check various values etc, here are a couple of thoughts (all of which are utter hacks, of course):</p>\n\n<ol>\n<li>Make the TRACE FILE a named pipe (assuming Unix back-end), so it blocks until you choose to read from it, or</li>\n<li>Create another table that your SPL polls for a particular entry from a WHILE loop, and insert said row from elsewhere (horribly inefficient)</li>\n<li>Make SET LOCK MODE your friend: execute "SET LOCK MODE TO WAIT n" and deliberately requery a table you\'re already holding a cursor open on. You\'ll need to wrap this in an EXCEPTION handler, of course.</li>\n</ol>\n\n<p>Hope that is some help (and if you\'re the same JS of Ars and Rose::DB fame, it\'s the least I could do ;-)</p>\n'}, {'answer_id': 51524006, 'author': 'robsosno', 'author_id': 229860, 'author_profile': 'https://Stackoverflow.com/users/229860', 'pm_score': 1, 'selected': False, 'text': '<p>I\'m aware that the answer is too late. However I\'ve recently encountered the same problem and this site shows as the first one. So it is beneficial for other people to place new anwser here.</p>\n\n<p>Perfect solution was found by Eric Herber and published in April 2012 here: <a href="http://informix.jfmiii.com/?p=151" rel="nofollow noreferrer">How to sleep (or yield) for a fixed time in a stored procedure</a>\nUnfortunately this site is down.</p>\n\n<p>His solution is to use following function:</p>\n\n<pre><code>integer sysadmin:yieldn( integer nseconds )\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/5667', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/164/']