Created
June 20, 2019 07:32
-
-
Save forstie/db96774f4f236b7284196e726b4ed1f2 to your computer and use it in GitHub Desktop.
Microsecond DLYJOB via SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Purpose: Delay job for fractions of a second | |
-- Author : Scott Forstie | |
-- Contact: forstie@us.ibm.com | |
-- Date : June 20, 2019 | |
cl: addlible QSYSINC; | |
cl: crtsrcpf qtemp/qcsrc; | |
cl: addpfm file(qtemp/qcsrc) mbr(usleep); | |
-- | |
-- The usleep() function suspends a thread for the number of microseconds specified by the of useconds parameter. | |
-- ============ | |
-- 1 sec == 1,000 milisec == 1,000,000 microsec == 1,000,000,000 nanosec | |
-- | |
insert into qtemp.qcsrc values | |
(1,010101,'{'), | |
(2,010101,'#include "unistd.h"'), | |
(3,010101,'while(USLEEP.SLEEPUS>1000000)'), | |
(4,010101,' { usleep(1000000); USLEEP.SLEEPUS-=1000000; }'), | |
(5,010101,'usleep(USLEEP.SLEEPUS);'), | |
(6,010101,'}'); | |
CREATE OR REPLACE PROCEDURE systools.usleep(sleepus int) | |
program type sub | |
-- Use this SET OPTION if you see a compile failure [SQL7032] | |
-- SET OPTION dbgview = *source, output=*PRINT | |
BEGIN | |
INCLUDE qtemp / qcsrc(usleep); | |
END; | |
-- Sleep for 1 microsecond | |
CALL systools.usleep(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My posting on showing lprintfs to the joblog provides a solution of sorts.
Scott