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 : forstie@us.ibm.com | |
-- Date : January 10, 2020 | |
-- ================================================================= | |
-- | |
-- Setup: | |
-- 1) create and populate the spreadsheet generator table | |
-- 2) change the procedure source code: |
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 : March 1, 2020 | |
-- Description: ODBC user activity comes in over QZDASxINIT jobs. | |
-- You can easily utilize a ZDA exit program to | |
-- identify specific SQL activity, when you | |
-- code your exit program to use QSYS2.PARSE_STATEMENT(). | |
-- | |
-- Here's the thing: | |
-- With the QSYS2.PARSE_STATEMENT() UDTF, you do not need to invent your own parser! |
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
-- Setup a sample database | |
call qsys.create_sql_sample('HIS_STORE'); | |
set schema his_store; | |
-- Create a view over sales. The view qualifies as an updateable and deletable view. | |
-- | |
-- Background: | |
-- Deletable views: A view is deletable if an INSTEAD OF trigger for the delete operation has been defined for the view, or if all of the following are true: | |
-- ================ | |
-- The outer fullselect identifies only one base table or deletable view that is not a catalog table or view. |
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
-- | |
-- The fastest way to find every user profile | |
-- | |
select objname as user_profile | |
from table ( | |
qsys2.object_statistics('QSYS', '*USRPRF', '*ALLSIMPLE') | |
); | |
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 : July 14, 2020 | |
-- | |
-- Question: How can I use SQL to validate that a string only contains an approved list of characters? | |
-- Answer : The TRANSLATE() built-in function. | |
-- | |
-- TRANSLATE replaces the allowed characters with blanks. | |
-- Then, RTRIM throws all the blanks away. | |
-- Then, if the resulting LENGTH is zero, you can conclude that the string only contained allowed characters. |
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
-- | |
-- Note: | |
-- Documentation for ACS's cldownload and other fantastic hidden gems can be found here: | |
-- ftp://ftp.software.ibm.com/as400/products/clientaccess/solutions/GettingStarted_en.html | |
-- | |
-- | |
-- Do I have the ACS jar on this IBM i? | |
-- | |
select create_timestamp, acs.* |
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
-- | |
-- title: Generate PDF(s) from Spooled Files | |
-- This scalar function allows the SQL programmer to identify Spooled File(s) and generate pdfs for them in the IFS. | |
-- | |
-- minvrm: V7R2M0 | |
-- | |
CREATE or replace FUNCTION SYSTOOLS.Generate_PDF( | |
job_name varchar(28) for sbcs data, | |
file_name varchar(10) for sbcs data, | |
file_number integer, |
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
-- =============================================== | |
-- Title: iSee how to track *ALLOBJ users | |
-- =============================================== | |
-- Date : November 5, 2020 | |
-- Author: Scott Forstie | |
-- Use : iSee video series with Tim Rowe | |
-- | |
-- ====================================================================================================== | |
-- |
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
-- | |
-- When an IFS directory includes W (write), you are exposed to malware attacks | |
-- Use this to review and overcome this topic for the all important ROOT directory | |
-- | |
-- For help on this or related security topics, contact Robert and team... | |
-- http://ibm.biz/IBMiSecurity | |
-- Robert Andrews - robert.andrews@us.ibm.com | |
-- | |
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
-- | |
-- I was asked how to incorporate row level auditing detail into tables. | |
-- While Temporal tables with Generated columns is a powerful combination, | |
-- the following example demonstrates a different approach. | |
-- | |
-- One fun aspect about the solution is the use of INCLUDE SQL on the triggers... | |
-- | |
-------------------------------------------------------------------------------------------------- | |
-------------------------------------------------------------------------------------------------- |