Sometimes it's useful to have the possibility to suspend a session for a specific time.
In other languages like Java, C, Shell, etc. is a sleep command available.
But as default there's no sleep command in DB2.
However it's very simple to create a stored procedure with exacly this behaviour:
db2 -td@ "create procedure s1.sleep (in sleeptime integer)
begin
declare wait_until timestamp;
set wait_until = (current timestamp + sleeptime seconds);
while (wait_until > current timestamp)
do
end while;
end
@
"
Another option is to wait to a specific timestamp:
create procedure sleep_until (in sleepuntil_timestamp timestamp)
begin
while (sleepuntil_timestamp > current timestamp)
do
end while;
end!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1477097/
,如需转载,请注明出处,否则将追究法律责任。