Hello Paolo,
assuming your task is to monitor for Temporary Storage consumption, as well as, you are on IBM i 7.4 and Db2 group PTF SF99704 level 13 and onward or IBM i 7.3 and group PTF SF99703 level 24 and onward, or IBM i 7.5, you could have a look at the Query Supervisor: https://www.ibm.com/docs/en/i/7.4?topic=tools-query-supervisor. You can use this to either look at the total execution time (elapsed time) or at the resource consumption, such as temporary storage allocation, I/O count or CPU time consumed. The Query Supervisor allows you to define thresholds for those characteristics, and when the defined threshold is exceeded, one or multiple user written exit programs are executed.
If you Google, you will find many information on how you can easily write your own exit program.
Good luck,
regards,
Nikos
------------------------------
NIKOS METAXATOS
------------------------------
Original Message:
Sent: Tue October 24, 2023 04:53 AM
From: Paolo Salvatore
Subject: Scrollable cursor usage
Hi,
I want to create a monitor then generate an alarm if a job exceed a specific quantity of memory, I'll use the sql function:
exec sql declare monitorRam scroll cursor for select JOB_NAME, X.JOB_NAME_SHORT, X.JOB_USER, X.JOB_NUMBER, AUTHORIZATION_NAME, TEMPORARY_STORAGE, X.CPU_TIME, SQL_STATEMENT_TEXT from table ( QSYS2.ACTIVE_JOB_INFO(DETAILED_INFO => 'ALL') ) X where JOB_TYPE <> 'SYS' order by TEMPORARY_STORAGE desc; exec sql open monitorRam; exec sql fetch first from monitorRam for 100 rows into :dsMonitor :dsnull;
Image then I made this check every minutes, but before doing the next fetch, Do I have to close the cursor?
I was wondering using a scrollable cursor I dind't have to declare, open and close the cursor every time, but with fetch first I could in loop receive a new result set.
Many thanks.
------------------------------
Paolo Salvatore
------------------------------