Three SQL statements to know by heart

If you’re still using DSPUSRPRF to create an *OUTFILE and querying over it, it’s time to stop. The entire #iBMi system has been in SQL for years. Here are three key SQL Statements you should know by heart:

1. To identify the jobs consuming the most CPU, use:

SELECT JOB_NAME, SUBSYSTEM, AUTHORIZATION_NAME, ELAPSED_CPU_PERCENTAGE FROM TABLE(QSYS2.ACTIVE_JOB_INFO(RESET_STATISTICS => 'YES')) ORDER BY ELAPSED_CPU_PERCENTAGE DESC FETCH FIRST 10 ROWS ONLY;

2. To check the ASP percent used before the message queue alerts you, run:

SELECT ASP_NUMBER, SYSTEM_ASP_USED, TOTAL_CAPACITY_AVAILABLE FROM QSYS2.ASP_INFO;

3. To get an overview of the entire system, execute:

SELECT * FROM QSYS2.SYSTEM_STATUS_INFO;

The advantage of SQL isn’t just its aesthetics; it’s about composition. You can join active jobs to user profiles, wrap it in a procedure, and schedule it to have the system email you when a threshold is reached. There’s no need for new products or purchase orders; it’s already available on your machine, with 5770-ST1.
Which command are you still using from the glorious “Green-screen” days?
Mine was WRKSYSSTS.

Originally posted on LinkedIn. Join the conversation there.

Get new posts by email

Practical IBM i tips on SQL services, security and backup, sent when I publish. No spam, unsubscribe anytime.

Leave a Reply