Skip to content

Instantly share code, notes, and snippets.

@BirgittaHauser
Created March 25, 2022 07:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BirgittaHauser/9f1b0db26002643bd74eb2eaca82ff75 to your computer and use it in GitHub Desktop.
Save BirgittaHauser/9f1b0db26002643bd74eb2eaca82ff75 to your computer and use it in GitHub Desktop.
Access Information returned from QLZARCAPI
-- User Defined Table Function: LicInfo_QLZARCAPI
------------------------------------------------------
-- Call QLZARCAPI - Retrieve the information written into the Joblog and split it into Description and Value
Create Or Replace Function YourSchema.LicInfo_QLZARCAPI ()
Returns Table (LicDescr VarChar(256),
LicValue VarChar(256))
Language SQL
Specific xQLZARCAPI
Deterministic
Modifies SQL Data
Called On NULL Input
Disallow Parallel
Set Option DBGVIEW = *SOURCE
Begin
Declare LocStartTs Timestamp Default '0001-01-01-00.00.00.000000';
Declare LocEndTs Timestamp Default '9999-12-31-24.00.00.000000';
---------------------------------------------------------------------------
-- Determine License Information by calling QLZARCAPI (Output into the Joblog!)
Set LocStartTS = Current_Timestamp;
Call QSYS.QLZARCAPI();
Set LocEndTs = Current_Timestamp;
Return (Select Cast(Substr(Element, 1, locate(':', Element) - 1)
as VarChar(256)) LicDescr,
Cast(Trim(Substr(Element, locate(':', Element) + 1))
as VarChar(256)) LicValue
From (Select RTrim(Trim(Substr(Message_Text,
Locate('->', Message_Text) + 3)),
'.') Text
From Table(QSYS2.Joblog_Info('*'))
Where From_Program = 'QLZARCAPI'
and Message_Timestamp between LocStartTS
and LocEndTS) x
cross join Table(Systools.Split(Text, '. ')));
End ;
Comment on Specific Function YourSchema.xQLZARCAPI
is 'License Information from the QLZARCAPI API';
-- Ho to call
Select * From Table(YourSchema.LicInfo_QLZARCAPI());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment