Skip to content

Instantly share code, notes, and snippets.

@NielsLiisberg
Last active September 29, 2022 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NielsLiisberg/ff5292d64c8cf87adc0a1d679ecd0ee9 to your computer and use it in GitHub Desktop.
Save NielsLiisberg/ff5292d64c8cf87adc0a1d679ecd0ee9 to your computer and use it in GitHub Desktop.
SQL send messages to joblog
-- Log a message to the joblog
--
-- This also showcase how to integrate the C code directly into your UDTF/Procedure
--
-- 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.
--
-- This 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.
--------------------------------------------------------------------------------------
call qsys2.ifs_write(
path_name => '/tmp/main.c' ,
file_ccsid => 1208,
overwrite => 'REPLACE',
line =>
'{
/* declare prototype for Qp0zLprintf */
extern int Qp0zLprintf (char *format, ...);
/* print input parameter to job log */
Qp0zLprintf("%.*s\n", JOBLOG.TEXT.LEN, JOBLOG.TEXT.DAT);
}'
);
create or replace procedure qusrsys.joblog (
text varchar(256)
)
external action
modifies sql data
set option output=*print, commit=*none, dbgview = *source --list
begin
include '/tmp/main.c';
end;
-- Usecase:
---------------------------------------------
call joblog('Test');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment