This file contains hidden or 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
-- Normally you can not update/insert or delete on read only view. | |
-- And view becomes "read only" if you have any calculation, | |
-- uses any scalar function or joins | |
-- | |
-- The trick here is to use a "instead-of trigger" where you control | |
-- the update, insert and delete process | |
-- | |
-- 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 - |
This file contains hidden or 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
-- Packing a numeric into a zoned buffer by using C runtime function. | |
-- The magic is done by the QXXDTOZ api and not external dependencies | |
-- | |
-- Simply paste this gist into ACS SQL and select "run all" | |
-- | |
-- 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 2020 | |
-- | |
-- This gist is distributed on an "as is" basis, without warranties |
This file contains hidden or 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
-- Export_schema_script and import_schema_script uses IBM generate_sql_objects | |
-- for building a export and import script in "perfect order" with IBM's SQL statements | |
-- in "perfect order" | |
-- | |
-- After exporting a schema definition you can then use the output script | |
-- to build an empty new version of the schema OR you can migrate | |
-- and upgrade an existing older version of the same schema with | |
-- a new layout. Perfect for CI/CD and development/production environment | |
-- | |
-- The clone_empty_schema is a combination of first running |
This file contains hidden or 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
-- Any_sort solves the problem where you have an alphanumeric column | |
-- that contains mixed numeric and alphanumeric data and you need to | |
-- order both alphanumeric AND numeric at the same time | |
-- | |
-- Any sort returns a varchar that left adjust alpha and right adjust numeric values | |
-- | |
-- Simply copy this gist and paste it into ACS SQL prompt. Select "run all" to build this feature. | |
-- | |
-- Note: I am using library QUSRSYS. I suggest you put it into your own tool library | |
-- |
This file contains hidden or 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
-- SQL procedure to get a quick system catalog of files, tables and views. | |
-- I use this from ACS all the time to get a catalog overview. | |
-- | |
-- Simply paste this gist into ACS SQL and select "run all" | |
-- | |
-- 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 2020 | |
------------------------------------------------------------------------------------- | |
create or replace procedure qusrsys.syscat ( |
This file contains hidden or 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
-- Let SQL create a command and CLLE program to run PASE shell | |
-- scripts or commands - much like QSH but for PASE. Ex. like this: | |
-- | |
-- SH SCRIPT('ls') | |
-- | |
-- Simply paste this gist into ACS SQL and select "run all" | |
-- | |
-- 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 2020 |
This file contains hidden or 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
-- Saves and restores Library into streamfile. local on the IFS or direct with HTTP from an URL | |
-- Note1: This uses my ftp_put_ifs and webget, also found on my Gist | |
-- Note2: 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 2020 | |
---------------------------------------------------------------------------------------------- | |
create or replace procedure qusrsys.savlib_to_ifs ( | |
library char(10), | |
stmf varchar(256) | |
) |
This file contains hidden or 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
-- FTP PUT and GET stream files from and to the IFS | |
-- This is a wrapper arround the IBM i FTP command, making it easy to simply | |
-- call this stored procedure to put and get to and from a FTP server | |
-- I doubt it is a good idea to build huge applications this way, however it | |
-- is a cool example how far you can go with SQL: Have fun :) | |
-- (C) Niels Liisberg 2020 | |
---------------------------------------------------------------------------------------------- | |
-- Need this template file for compile | |
create or replace table qtemp.ftplog(line char(240)) on replace delete rows; |
This file contains hidden or 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
-- Write a BLOB to IFS | |
-- Note1: This also works for save files | |
-- Note2: This also compiles on vanilla systems without QSYSINCL installed | |
-- Note3: I am using library QUSRSYS. I suggest you put it into your tool library | |
-- I doubt it is a good idea to build huge applications this way, however it | |
-- is a cool example how far you can go with SQL: Have fun :) | |
-- (C) Niels Liisberg 2020 | |
---------------------------------------------------------------------------------------------- | |
call qcmdexc ('crtsrcpf FILE(QTEMP/C) MBR(C)'); | |
delete from qtemp.c; |
This file contains hidden or 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
-- Get a stream file via the HTTP/HTTPS protocol and store it on the IFS. | |
-- This was inspired by the "wget" AIX command, that is not always available | |
-- Note1: This also works for save files | |
-- Note2: This also compiles on vanilla systems without QSYSINCL installed | |
-- Note3: I am using library QUSRSYS. I suggest you put it into your tool library | |
-- I doubt it is a good idea to build huge applications this way, however it | |
-- is a cool example how far you can go with SQL: Have fun - | |
-- (C) Niels Liisberg 2020 | |
---------------------------------------------------------------------------------------------- | |
call qcmdexc ('crtsrcpf FILE(QTEMP/C) MBR(C)'); |