Skip to content

Instantly share code, notes, and snippets.

@forstie
forstie / Data driven emails from IBM i.sql
Last active March 26, 2025 19:53
The request... send emails using data driven email recipient specifications. The implementation is 100% SQLcandoit.
--
-- Subject: Data driven emails from IBM i
-- Author: Scott Forstie
-- Date : May, 2024
-- Features Used : This Gist uses SQL PL, listagg, SYSTOOLS.GENERATE_SPREADSHEET, SYSTOOLS.SEND_EMAIL, and database know-how
--
-- Now that it's simple to generate spreadsheets and send emails from the IBM i, the request was to
-- send emails and NOT have the recipient(s) of the email hard-coded.
--
-- One solution is found below. Store the email recipients within a Db2 for i table and
@forstie
forstie / SQL DDL with nc.sql
Created April 26, 2021 11:41
SQL DML includes the WITH NC clause to avoid having the data change participate in the transaction. SQL DDL does not include the WITH NC clause, but the savvy SQL user can leverage an AUTONOMOUS procedure to achieve the same behavior.
-- 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 '',