DB2 PL/SQL Example: Sleep Procedure
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!
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部落格 ” ,連結:http://blog.itpub.net/22661144/viewspace-1477097/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DB2 PL/SQL Example: RunstatsDB2SQL
- DB2 PL/SQL Example: bonus_increaseDB2SQL
- PL/SQL 05 儲存過程 procedureSQL儲存過程
- DB2 PL/SQL How much reorganisations are recommended on a specific schemaDB2SQL
- 使用after create 建立trigger記錄procedure PL/SQL程式碼變更SQL
- oracle procedure儲存過程(pl/sql)_使用declare cursor_begin end巢狀Oracle儲存過程SQL巢狀
- utlrp.sql 一次性統一編譯無效物件(pl/sql procedure等)SQL編譯物件
- sql primary key procedureSQL
- PL/SQLSQL
- EXECUTE IMMEDIATE dynamic sql in procedureSQL
- 分頁procedure (SQL Server)SQLServer
- SQL&PL/SQL (轉)SQL
- PL/SQL 宣告SQL
- PL/SQL cursorSQL
- PL/SQL打包SQL
- PL/SQL DEVSQLdev
- Oracle PL/SQLOracleSQL
- 使用PL/Scope分析PL/SQL程式碼SQL
- PLSQL Language Reference-PL/SQL概覽-PL/SQL架構SQL架構
- [PL/SQL]10g PL/SQL學習筆記(一)SQL筆記
- [PL/SQL]10g PL/SQL學習筆記(二)SQL筆記
- [PL/SQL]10g PL/SQL學習筆記(三)SQL筆記
- SQL 建立儲存過程PROCEDURESQL儲存過程
- PL/SQL 迴圈SQL
- PL/SQL 遊標SQL
- PL/SQL 運算子SQL
- PL/SQL 條件SQL
- pl/sql to_dateSQL
- PL/SQL 基礎SQL
- Oracle PL/SQL INDICESOracleSQL
- PL/SQl Developer使用SQLDeveloper
- pl/sql陣列SQL陣列
- pl/sql練習SQL
- oracle PL/SQL示例OracleSQL
- 淺談pl/sqlSQL
- PL/SQL 索引表SQL索引
- pl/sql 練習SQL
- [pl sql] where current ofSQL