Skip to content

Instantly share code, notes, and snippets.

@chrishiebert
chrishiebert / RtnDspAtr.RPGLE
Created August 18, 2022 16:54
RtnDspAtr Return Display Attribute hex code for RPGLE and 5250 screens.
// Based: Croy, Steve (2005) Display-attributes-made-simple/setcolor [Source code]. http://search400.techtarget.com/tip/Display-attributes-made-simple
// --------------------------------------------------
// Procedure name: RtnDspAtr
// Purpose: Return Display Attribute hex code that can be used on a
// screen to set color, underline, or other attributes.
// Returns: DSPATR hex value
// Parameter: Color Value - Text representing a color 'GRN' (default)
// other values: 'BLU' 'PNK' 'RED' 'TRQ' 'WHT' 'YLW'
@chrishiebert
chrishiebert / GenerateMerge.SQL
Created September 19, 2023 16:12
Generate a Merge Statement on IBM iSeries DB2UDB.
-- Change THETABLENAME to the table you want to reference. It must already exist.
WITH T1 ( Table_Name, Table_Prefix, Table_Prefix2) As ( values( Ucase('THETABLENAME'), 'T1.', 'T2.' ) )
, I1 (INDEX_NAME, INDEX_SCHEMA, Table_Name, Table_Prefix, Table_Prefix2 ) as (
Select I1.INDEX_NAME, I1.INDEX_SCHEMA, t1.Table_Name, t1.Table_Prefix, t1.Table_Prefix2
From SYSINDEXES I1
Join T1 Using (Table_Name)
ORDER BY CASE
WHEN IS_UNIQUE = 'U' then 1