Skip to content

Instantly share code, notes, and snippets.

View alanseiden's full-sized avatar

Alan Seiden alanseiden

View GitHub Profile
@forstie
forstie / Are programs in QRPLOBJ being used.sql
Created February 8, 2023 00:13
The request here was simple, are there active jobs that had objects in QRPLOBJ on the stack? The solution was a little tricky, because jobs can end in the middle of doing the analysis.
--
-- Subject: Are we running with *PGMs or *SRVPGMs that reside within QRPLOBJ?
-- Author: Scott Forstie
-- Date : February, 2023
-- Features Used : This Gist uses qsys2.stack_info, CTEs, PIPE, SQL PL
--
-- Notes:
-- ===============================================
-- 1) Programs and Serice Programs get moved to QRPLOBJ when they are (re)created with replace(*YES).
-- 2) It is not safe to delete *PGMs or *SRVPGMs from QRPLOBJ, if you base your decision upon locks.
@forstie
forstie / JSON_TABLE and survival tips for shredding JSON with SQL
Last active August 12, 2024 08:06
This example shows how to overcome what seems to be commonplace: JSON Web Services that return an invalid JSON document.
-- This fails to return data....why?
SELECT cusip, issueDate, bidToCoverRatio
FROM JSON_TABLE(
SYSTOOLS.HTTPGETCLOB('https://www.treasurydirect.gov/TA_WS/securities/announced?format=json&type=FRN&pagesize=5', null),
'$.root[*]'
COLUMNS(cusip VARCHAR(10) PATH '$.cusip',
issueDate Timestamp PATH '$.issueDate',
bidToCoverRatio double PATH '$.bidToCoverRatio')
) AS X;
stop;