Skip to content

Instantly share code, notes, and snippets.

View NielsLiisberg's full-sized avatar

Niels Liisberg NielsLiisberg

View GitHub Profile
@NielsLiisberg
NielsLiisberg / service_program_procedure_exports.sql
Created September 29, 2022 16:08
service program procedure exports
-- List service program procedure exports
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- It is a cool example how far you can go with SQL: Have fun 😀
-- (C) Niels Liisberg 2022
--
-- This gist is distributed on an "as is" basis, without warranties
-- or conditions of any kind, either expressed or implied.
----------------------------------------------------------------------------------------------
-- convert BLOB to a bsae64 CLOB in UTF-8
-- This also showcase how to integrate the C code directly into your UDTF
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- It is a cool example how far you can go with SQL: Have fun 😀
-- (C) Niels Liisberg 2022
--
-- This gist is distributed on an "as is" basis, without warranties
-- or conditions of any kind, either express or implied.
@NielsLiisberg
NielsLiisberg / enable_netserver_user.sql
Last active June 29, 2022 08:17
SQL re-enable net user
-- Enable netserver user
-- This also showcase how to integrate the C code directly into your UDTF
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- It is a cool example how far you can go with SQL: Have fun 😀
-- (C) Niels Liisberg 2022
--
-- This gist is distributed on an "as is" basis, without warranties
-- or conditions of any kind, either express or implied.
@NielsLiisberg
NielsLiisberg / system_name.sql
Created June 22, 2022 15:55
SQL Retrieve system name by MI call
-- Retrieve the system name by call to MI
-- This also showcase how to integrate the C code directly into your UDTF
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- It is a cool example how far you can go with SQL: Have fun 😀
-- (C) Niels Liisberg 2022
--
-- This gist is distributed on an "as is" basis, without warranties
-- or conditions of any kind, either express or implied.
@NielsLiisberg
NielsLiisberg / rename_local_database.sql
Created June 21, 2022 14:15
SQL rename local default database to system name
-- When indexes are created in one languate - they will not be usable in other languages.
--
-- This procedure simply replaces the current *LOCAL
-- database name with the name of the system name
--
-- Simply paste this gist into ACS SQL and step through the code.
--
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library
--
-- It is a cool example how far you can go with SQL: Have fun 😀
@NielsLiisberg
NielsLiisberg / table_access_sequence.sql
Created June 21, 2022 12:44
SQL table access sequence
-- When indexes are created in one languate - they will not be usable in other languages.
--
-- This table function returns a list of access to tables by
-- national char features. By analysing the SQSSEQ and language
-- combined with the job CCSID and language, is can be determind
-- if an inex will be used on not.
--
-- Simply paste this gist into ACS SQL and step through the code.
--
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library
@NielsLiisberg
NielsLiisberg / drop_old_files.sql
Last active August 2, 2022 13:57
SQL Drop old backup files made by RSTOBJ commd
-- This procedure deletes old backup files produced
-- when the RSTOBJ command restores file objects.
--
-- It uses the regex to filter the names of the files
-- the RSTOBJ command gives these file objets in the rename process.
--
-- Simply paste this gist into ACS SQL and step through the code.
--
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library
--
@NielsLiisberg
NielsLiisberg / udtf-intro.sql
Last active June 13, 2023 12:22
SQL Db2 for IBM i - introduction to UDTF
-- SQL Db2 for IBM i - introduction to UDTF
--
-- This is a tutorial starting with SQL functions, over User defined Table Function (UDTF)
-- and procedures. It covert the basic features and some common pitfalls.
-- By using IBM i SQL service as the vehicle for making service calls over http and integrate data
-- from Db2 on the IBM i makes this tutorial super relevant.
--
-- It is a cool example how far you can go with SQL: Have fun -
-- (C) Niels Liisberg 2022
@NielsLiisberg
NielsLiisberg / job_is_waiting_for.sql
Last active December 13, 2021 15:17
Who is locking my database resources
-- Returns the job name that is locking resources for another job
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library
--
-- It is a cool example how far you can go with SQL: Have fun -
-- (C) Niels Liisberg 2021
--
-- This gist is distributed on an "as is" basis, without warranties
@NielsLiisberg
NielsLiisberg / format_message.sql
Created October 28, 2021 16:01
Format messages ID and messages data into text
-- Format a message from messag ID and messages data
-- This also showcase how to integrate the C code directly into your UDTF
--
-- Simply paste this gist into ACS SQL and step through the example.
--
-- It is a cool example how far you can go with SQL: Have fun -
-- (C) Niels Liisberg 2021
--
-- This gist is distributed on an "as is" basis, without warranties
-- or conditions of any kind, either express or implied.