Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
SQL iQuery Documentation - UDF and UDTF
has no ratings.
Published: 04 Sep 2019
Revised: 04 Sep 2019 - 411 days ago
Last viewed on: 19 Oct 2020 (243 views) 
  1. SQL iQuery - RUNiQRY CL Command
  2. CSV() - Read and Parse Comma Separated Values File
  3. CSV_VAL() Extract CSV Column Value
  4. CSV_XXXX() Extract CSV Column Value as xxxx
  5. CSV_COUNT - Retrieve Field Count
  6. ObjExist - Check Object Exits
  7. DTAARA - Data Area
  8. encode_URL Encode URL for the Web
  9. encode_TAG Encode HTML TAG Content
  10. FLDLIST - List the Fields of a Table
  11. FROMHEX - Fold 2-hex Chars into 1 Char
  13. MD5_HASH - UDF - Return MD5 Hash
  14. ifsStat - Get IFS File Attributes
  15. ifsExists - Check if IFS File Exists
  16. ifsFile - Query Contents of IFS Text File
  17. ifsDIR - List IFS Directory Entires
  18. DEPFILE - List Dependent Database Relations
  19. JOB - Get Job Name Component
  20. Job_ATTR - Job Attributes
  21. JOB_DATE Retrieve the Job Date
  22. JOBLOG - Write Message to Joblog
  23. Library List UDF and Procedures
  24. MBRLIST - Member List
  25. MCHINFO Machine Type and Model Number and OS version
  26. OSVER and OSVRM Get IBM i Version/Release
  27. PrintPDF - Print a PDF to a PDF Compatible Printer
  28. CPYTOPDF - Copy SPOOLED File to PDF file
  29. OBJ_LIST List Object in a Library
  30. LIB_LIST List Descriptions of Libraries on the Library List
  31. OBJ_EXPORTS List Exported Items from an Object
  32. OBJ_STRUCT Retrieve Objects Components
  33. RTVCMDD Retrieve Command Definition
  34. RTVJOBA - Retrieve Job Attributes
  35. RTVJOBD - Retrieve Job Description
  36. RTVLASTSPLF - Retrieve ID of Last SPOOLED File for this Job
  37. RTVxxx - Retrieve Various Objects Description Table Functions
  38. WATCHLIST - List Current Watches
  39. Polymorphic Qualified Name Syntax

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

iQuery.watchList - UDTF List Current Watches Published by: Bob Cozzi on 04 Sep 2019 view comments

List Current Watchs (from the STRWCH Command)

The iQuery.watchList() UDTF returns one row for each watch.

The information returned in similar to the WRKWCH command.

UDTF Return Type Description
watchList TABLE Returns a resultSet containing information about the active Watches.


iQuery.watchList( watch_type, Origin, session_user,  watchStatus, session_ID )

All parameters are optional and default to *ALL.

The watch_Type is the Watch Session Type. This equates to the WCH (Watch) Parameter of the WRKWCH CL command. The valid chocies are *ALL (the default), *SRVMON, *STRWCH, or *TRCCMD.

The Origin is the original of the watch. It is similar to the Watch_Type paramter but gives you more granular options. The valid choices are *ALL (the default), QSCSWCH, STRWCH, STRTRC, STRCMNTRC, TRCINT, TRCCNN, and TRCTCPAPP. Leading * asterisk may be specified and is ignored.

The session_User is the User Profile of the user who started the Watch Session. The valid choices are *ALL (the default), * or *CURRENT (current user), or a specific user profile name.

The watchStatus is the current status of the watch session. The valid choices are *ALL (the default), *ACTIVE (the sesion is active) or *ENDING (the session is currently ending). Note the leading * asterisk is optional.

The session_ID is the session identifier assigned to the watch. This parameter may be *ALL (the default), a generica session ID, or a specific session ID.

Result Set Columns

Column Type Description
SESSIONID varchar(10) The Watch Session ID.
WATCHTYPE varchar(10) The type of watch (*SRVMON, *STRWCH, *TRCCMD)
ORIGIN varchar(10) The Command or API used to create the watch.
STARTED_BY_USER varchar(10) The User Profile of the User who created the watch.
STATUS varchar(10) Watch Status (ACTIVE or ENDING)
WATCH_PGM varchar(10) Program to call on watch events.
WATCH_PGMLIB varchar(10) Library name for Program to call on watch events.
JOBNAME varchar(10) The job name for the watch job.
JOBUSER varchar(10) The job user for the watch job.
JOBNBR varchar(6) The job number for the watch job.
start_date date The date the watch was started.
start_time time The time the watch was started.
msgWatched integer Number of messages being watched.
MSGID char(7) The message ID of the first message being watched.
MSGTYPE varchar(10) The message type of the first message being watched.
MSGSEV smallint The message severity of the first message being watched.
MSGQ varchar(10) The message queue name of the first message being watched.
MSGQLIB varchar(10) The message queue library of the message queue of the first message being watched.
WATCHED_JOBNAME varchar(10) The Job name of the job being watched.
WATCHED_JOBUSER varchar(10) The User Profile of the job being watched.
WATCHED_JOBNBR varchar(6) The Job number of the job being watched.
CALLOPTIONS varchar(32) An array of the Options that identify additional times when the Called Watch Program is called.


select * from table( iQuery.watchList() ) wl;

This creates a list of all active watches.

Return to midrangenews.com home page.
Sort Ascend | Descend