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: 20 Jun 2019
Revised: 20 Jun 2019 - 1794 days ago
Last viewed on: 14 May 2024 (949 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.obj_list UDTF Published by: Bob Cozzi on 20 Jun 2019 view comments

List Object Descriptions of Objects in a Library

The iQuery.obj_list() UDTF returns one row for each object that matches the search criteria.


iQuery.obj_list( library-name, object-name, object-type, object-status )

The library-name is the name of the library that contains the objects to be listed. In addition to a specific library name, the special values *ALL, *ALLUSR, *USRLIBL, *LIBL, and *CURLIB may be specified.

The optional object-name is the name of the object to be included. A generic or full name may be specified. The default is *ALL.

The optional object-type specifies the whose fields propertiestype of objects to be listed. The default is *ALL Any valid IBM i operating system object type may be specified.

The optional object-status can be *, *ALL, D, P, or DP. * and *ALL mean all objects. D means damaged objects and P means partially damaged objects. When D or P is specified, only objects that match those statuses are returned. *ALL or * return all objects regardless of status. The use of D and/or P is to isolate the list to damaged or partially damaged objects only.

Result Set Columns

Column Type Description
OBJNAME varchar(10) The name of the object whose description has been returned in this row.
OBJLIB varchar(10) The library name of the object.
OBJTYPE varchar(10) The Object Type of the object.
OBJSTATUS char(1) The object damaged or locked status. D=Damaged, P=Partial Damage, L=Object Locked.
OBJTEXT varchar(50) The text description for the object.
OBJOWNER varchar(10) The owner of the object.
OBJCREATOR varchar(10) The user profile that created the object.
CRTDATE DATE The object Creation Date.
CRTTIME TIME The object Creation Time
CRTSYSNAME varchar(10) The system on which the object was created.
DAMAGED varchar(10) Damed Object Attribute: *DAMAGED, *PARTIAL or blank.
ASP smallint The ASP where the object exists.
DOMAIN varchar(10) The domain where the object exists (system or user domain)
CRTVRM varchar(9) The version of IBM i on which the object was created. The format is VxRyMz
TGTRLS varchar(9) The value of the TGTRLS parameter when the object was created. The format is VxRyMz
ACTGRP varchar(10) The name of the activation group in which the object runs if *PGM or *SRVPGM. The special values *DFTACTGRP, *NEW, and *CALLER may also be returned.
CGHDATE DATE The Last Changed Date of the object.
CHGTIME TIME The Last Changed Time of the object.
SRCFILE varchar(10) The source file used to create the object (if any).
SRCLIB varchar(10) The source library that contains the source file used to create the object (if any)
SRCMBR varchar(10) The source member name used to create the object (if any)
LASTSAVEDDATE DATE Last Date when a save of the object occurred.
LASTSAVEDTIME TIME Last Time a save of the object occurred.
LASTRESTOREDDATE DATE The date when the object was last restored.
LASTRESTOREDTIME TIME Last Time the object was restored.
LASTUSEDDATE DATE The date when the object was last used.
LASTUSEDTIME TIME The time on the last used date when the object was used (often not specified)
DAYSUSED INT The number of days the object has been used.


The following creates a list of all objects in library COZTOOLS and includes the creation date and last used date.

select objname, objlib, objtype, crtdate, lastUsedDate, daysUsed 
from table(iquery.obj_list('COZTOOLS')) OL

An excerpt from the resultSet generated by the above statement follows:

COZLANGEN   COZTOOLS    *MSGF       2014-08-28    2019-06-18          947 
COZTOOLS    COZTOOLS    *MSGF       2013-10-28    2019-06-09          429 
APPTOOLS    COZTOOLS    *FILE       2014-04-04    2019-06-20         1494 
ASKDATE     COZTOOLS    *FILE       2018-11-05    2019-06-09            3 
ASKUSER     COZTOOLS    *FILE       2018-11-05  ----------              0 
CLPSAMPLES  COZTOOLS    *FILE       2013-03-21    2018-11-05           67 
COZASCPRN   COZTOOLS    *FILE       2012-10-23    2018-11-05           42 
COZEVENTS   COZTOOLS    *FILE       2012-06-29  ----------              0 
COZSAVSPLF  COZTOOLS    *FILE       2012-07-28  ----------              0 
COZSYSDFT   COZTOOLS    *FILE       2012-05-16  ----------              0 
EDITCODES   COZTOOLS    *FILE       2015-07-16    2019-06-05            2 
EVFEVENT    COZTOOLS    *FILE       2018-07-02    2019-06-20          278 

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