Skip to content

Instantly share code, notes, and snippets.

View dancarlosgabriel's full-sized avatar

Reynaldo Dandreb M. Medilla dancarlosgabriel

  • Moorepay/Zellis, Ceridian/Ascender, Frontier Communications/Trbhi, NGA/Weserve Fujitsu,Cargill,BDO,Honda
  • Philippines
View GitHub Profile
@greghelton
greghelton / StoredProcWriter.java
Last active November 28, 2023 00:06
Java that writes Java code that calls an AS400 stored procedure. This program reads the SYSPARMS table and gets the number and types of the stored procedure's parms and writes the connecting Java code. This code requires a properties file named AS400DEV.properties and this file must have values for system, userid and password.
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.util.Vector;
import java.util.Enumeration;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.sql.SQLException;
import java.io.IOException;
@RainerRoss
RainerRoss / GETJSONIFS.SQLRPGLE
Last active July 8, 2024 17:56
Read JSON from IFS in RPGLE
ctl-opt dftactgrp(*no) option(*nodebugio:*nounref);
//------------------------------------------------------------------//
// //
// Get JSON from IFS //
// //
//----------------- //
// R.Ross 07.2018 * //
//------------------------------------------------------------------//
// Array SQL-Result //
//------------------------------------------------------------------//
@forstie
forstie / Temporalize a library.sql
Created November 8, 2019 13:59
System period temporal tables were added as a feature built into Db2 for i with IBM i 7.3. This example shows how Temporal could be established for all database files within a specific library.
--
--
-- description: find database files and deploy Temporal over them
-- note: The history table will be named <existing-table-name>_HISTORY
-- note: Uncomment the LPRINTF's if you've built this procedure or have it from Db2 for i
-- minvrm: V7R3M0
--
CREATE OR REPLACE PROCEDURE coolstuff.deploy_temporal(target_library varchar(10))
BEGIN
@forstie
forstie / Generating spreadsheets with SQL.sql
Last active June 17, 2024 16:09
In this working example, we establish an SQL table which contains the spreadsheets we'd like to have generated. Each row in the table includes the query that will supply the data for the spreadsheet, and the location in the IFS where the spreadsheet should reside. Further, a different procedure emails the spreadsheets to an interested consumer. …
-- =================================================================
-- 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:
@BirgittaHauser
BirgittaHauser / ReadCsv.SQL
Created January 30, 2020 05:18
Read *.csv File directly with SQL
-- Read *csv File from IFS
With x as (-- Split IFS File into Rows (at CRLF)
Select Ordinal_Position as RowKey, Element as RowInfo
from Table(SysTools.Split(Get_Clob_From_File('/home/Hauser/Employee.csv'), x'0D25')) a
Where Trim(Element) > ''),
y as (-- Split IFS File Rows into Columns (and remove leading/trailing double quotes ")
Select x.*, Ordinal_Position ColKey,
Trim(B '"' from Element) as ColInfo
from x cross join Table(SysTools.Split(RowInfo, ',')) a)
-- Return the Result as Table
@dancarlosgabriel
dancarlosgabriel / ReadCsv.SQL
Created January 31, 2020 23:03 — forked from BirgittaHauser/ReadCsv.SQL
Read *.csv File directly with SQL
-- Read *csv File from IFS
With x as (-- Split IFS File into Rows (at CRLF)
Select Ordinal_Position as RowKey, Element as RowInfo
from Table(SysTools.Split(Get_Clob_From_File('/home/Hauser/Employee.csv'), x'0D25')) a
Where Trim(Element) > ''),
y as (-- Split IFS File Rows into Columns (and remove leading/trailing double quotes ")
Select x.*, Ordinal_Position ColKey,
Trim(B '"' from Element) as ColInfo
from x cross join Table(SysTools.Split(RowInfo, ',')) a)
-- Return the Result as Table
@dancarlosgabriel
dancarlosgabriel / gist:b2cc3d867c6e1eb810853c56e137feea
Created April 26, 2020 12:03 — forked from Faq400Git/gist:72431bdeb7998b081cce3b29cb0fe89a
Get Euro Exchange Rates from ECB/BCE WebService
ctl-opt dftactgrp(*no) ;
//-----------------------------------------------------------------------*
// TS_BCE: Get Exchange Rate from ECB/BCE Web Service
// This source is part of Faq400 Blog's post
// https://blog.faq400.com/it/?p=2648
//-----------------------------------------------------------------------*
dcl-pr qCmdExc ExtPgm('QCMDEXC');
@BirgittaHauser
BirgittaHauser / SearchSrcMbr
Created November 5, 2020 15:44
How to search source physical file member for a specific String
It was just a question in a Forum: How to search (all) source physical file members for a specific string and list all those members
In this examples all source files beginning with "QSRC" in the "YOURSCHEMA" library are searched whether they include "String".
All Source Members that include "String" are returned
With a as (Select a.System_Table_Schema OrigSchema,
a.System_Table_Name OrigTable,
a.System_Table_Member OrigMember,
Trim(System_Table_Schema) concat '/' concat
Trim(System_Table_Name) concat '(' concat
Trim(System_Table_Member) concat ')' as OrigCLOBMbr
@BirgittaHauser
BirgittaHauser / Scan_All_Spoolfiles_in_an_Outqueue.sql
Last active September 4, 2022 14:04
Scan through all spoolfiles in a specific outqueue
-- Scan through all spoolfiles in a specific outqueue (e.g. QEZJOBLOG) for a specific string
Select a.Job_Name, Spooled_File_Name, File_Number, Spooled_Data
-- , a.*
from OutPut_Queue_Entries a Cross Join
Lateral(Select *
From Table(SysTools.Spooled_File_Data(
Job_Name => a.Job_Name,
Spooled_File_Name => a.Spooled_File_Name,
Spooled_File_Number => File_Number))) b
Where Output_Queue_Name = 'QEZJOBLOG'
@forstie
forstie / ddm server.sql
Created June 4, 2022 15:23
The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it.
--
-- Subject: The request... use SQL to determine if the DDM/DRDA server was active, and if not, start it.
-- Author: Scott Forstie
-- Date : June, 2022
-- Features Used : This Gist uses QSYS2.ACTIVE_JOB_INFO, BOOLEAN, QSYS2.QCMDEXC scalar function, CTE, case expression
--
--
-- Is the DDM/DRDA listener active? (If at IBM i 7.4 or earlier)
--
select count(*) as DDM_DRDA_Listener_Active