This file contains 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
-- Assumption... the connection is setup to use COMMIT(*CHG) | |
-- ========================================================================= | |
-- | |
-- By default, SQL Data Definition Language (DDL) cannot use WITH NC | |
-- | |
-- ========================================================================= | |
CREATE TABLE QTEMP.T035 (FLD1 CHARACTER (9) CCSID 37 NOT NULL DEFAULT '', | |
FLD2 CHARACTER (30) CCSID 37 NOT NULL DEFAULT '', |
This file contains 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... | |
-- | |
-------------------------------------------------------------------------------------------------- | |
-------------------------------------------------------------------------------------------------- |
This file contains 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 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
-- | |
-- Use NAMING(*SYS) - system naming mode to leverage the power of the library list | |
-- | |
cl: crtlib lib1; | |
cl: crtlib lib3; | |
cl: crtlib lib2; | |
cl:CRTDUPOBJ OBJ(QSQPTABL) FROMLIB(QSYS2) OBJTYPE(*FILE) TOLIB(LIB1) DATA(*YES); | |
cl:CRTDUPOBJ OBJ(QSQPTABL) FROMLIB(QSYS2) OBJTYPE(*FILE) TOLIB(LIB2) DATA(*YES); | |
cl:CRTDUPOBJ OBJ(QSQPTABL) FROMLIB(QSYS2) OBJTYPE(*FILE) TOLIB(LIB3) DATA(*YES); | |
cl: addlible lib1; |
This file contains 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
-- To be able to audit holding of a job queue, you need to: | |
-- 1) Enable object auditing | |
-- 2) Configure object auditing for specific job queues | |
cl: CHGSYSVAL SYSVAL(QAUDCTL) VALUE('*AUDLVL *OBJAUD *NOQTEMP'); | |
cl: CHGOBJAUD OBJ(QGPL/KIDDIEJOBQ) OBJTYPE(*JOBQ) OBJAUD(*CHANGE); | |
stop; | |
-- | |
-- T-ZC audit journal entry: | |
-- https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzarl/rzarlf77.htm |
This file contains 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
-- | |
-- description: What are ALL my interactive users doing right now? (summary) | |
-- ==== | |
-- | |
select j.authorization_name as user_name, u.text_description as description, | |
count(*) as job_count | |
from qsys2.user_info as u | |
join table ( | |
qsys2.active_job_info( | |
subsystem_list_filter => 'QINTER', detailed_info => 'ALL') |
This file contains 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
-- | |
-- Find active jobs (in QBATCH) that are in message wait status | |
-- | |
with msgw_jobs (jn) as ( | |
select job_name | |
from table ( | |
qsys2.active_job_info(subsystem_list_filter => 'QBATCH') | |
) x | |
where job_status = 'MSGW' | |
) |
This file contains 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
-- | |
-- Complete review of special authorities granted to user profiles | |
-- | |
select user_name, ordinal_position, ltrim(element) as special_authority | |
from qsys2.user_info, table ( | |
systools.split(rtrim(special_authorities), ' ') | |
) b | |
where user_name not in (select authorization_name | |
from qsys2.authids | |
where authorization_attr = 'GROUP'); |