This file contains hidden or 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
-- | |
-- category: Software Resources | |
-- description: DSPSFWRSC for SQL users | |
-- | |
create or replace function coolstuff.whatsinstalled () | |
returns table ( | |
product varchar(7) ccsid 37, load integer, option integer, | |
software_text varchar(132) ccsid 37 | |
) | |
external action |
This file contains hidden or 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
-- | |
-- Existing file... not very user friendly | |
-- | |
create schema gggr; | |
create table gggr.sales ( | |
CL varchar(100), | |
PTY varchar(100), | |
SP varchar(30), | |
PG char(1) | |
); |
This file contains hidden or 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
-- | |
-- Traditional 3-part name SQL would reference a table, view, or procedure | |
-- | |
call otherRDB.schema.procedure123(); | |
stop; | |
insert into localschema.fact_table | |
select * from otherRDB.remoteschema.fact_table; | |
stop; |
This file contains hidden or 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
-- ============================================================= | |
-- Author: Scott Forstie | |
-- Date : September 8, 2019 | |
-- Revised: August 28, 2020 | |
-- | |
-- Description: Have you ever wondered what's driving all | |
-- those QZDASxINIT jobs? | |
-- This example shows how to establish an | |
-- exit program to capture client special register | |
-- and other detail for ZDA connections. |
This file contains hidden or 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
create procedure qgpl.values_into (out pout integer) | |
begin | |
declare values_into_stmt varchar(1000) ccsid 37; | |
set values_into_stmt = 'values 1+2+3 into ?'; | |
prepare values_into_query from values_into_stmt; | |
execute values_into_query using pout; | |
end; | |
call qgpl.values_into(?); | |
-- Note that 6 is returned... |
This file contains hidden or 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
values current decfloat rounding mode; | |
set current decfloat rounding mode= round_half_even; | |
stop; | |
-- =============================================================================================================== | |
-- | |
-- QUANTIZE uses the decfloat rounding mode. | |
-- This is the default: ROUND_HALF_EVEN | |
-- | |
-- Round to nearest value; if values are equidistant, round so that the final digit is even. | |
-- If the discarded digits represent greater than half (0.5) of the value of a number in the next left position, |
This file contains hidden or 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
-- 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; |
This file contains hidden or 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
-- Author: Scott Forstie | |
-- Email : [email protected] | |
-- Date : July 28, 2019 | |
-- | |
-- Subtract '*IOSYSCFG from all users by producing the CHGUSRPRF command | |
-- necessary to get the job done | |
-- | |
with iosyscfg_users (user_name) as ( | |
select authorization_name | |
from qsys2.user_info |
This file contains hidden or 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
-- Author: Scott Forstie | |
-- Email: [email protected] | |
create or replace variable coolstuff.decdate dec(6,0); | |
set coolstuff.decdate = '190718'; | |
-- July 18, 2019 (yes, really!) | |
values timestamp_format(varchar(coolstuff.decdate), 'YYMMDD'); | |
-- Wow | |
-- Yowza |