COMMANDS

Support email

www.MidrangeNews.com

Contact Us

SQL iQuery Logo

SQL iQuery

Macro Support

SQL iQuery macros provide a shortcut way to run lengthy SQL statements that may or may not be wrapped up in SQL iQuery Script statements. The benefit is that it is shorter syntax to run these lengthy statements, it provides a way to "name" these scripts, provides a level of indirection, and you have the added advantage of using all the OUTPUT and other options of the SQL iQuery engine. Need a list of Active Jobs in Excel format? No problem!

RUNiQRY *ACTJOB OUTPUT(*EXCEL) EMAIL(BOB@coztools.com)

Normally, to run an SQL statement, you specify it on the SQL parameter of the RUNIQRY command as follows:

RUNIQRY SQL('SELECT * FROM QIWS/QCUSTCDT')

You can also save the SQL statement into a source member and recall it later by referencing the source member name, as follows:

RUNIQRY SRCMBR(SAMPLE) SRCFILE(MYLIB/QSQLSRC)

Another great feature in SQL iQuery allows users to store SQL statements in source members and easily recall them using the Macro syntax. This is a kind of "short cut" to the SQL statements and iQuery Script stored in the source member. We call this feature Macro support.

Using the RUNIQRY command, users may run pre-written SQL statements using the member name and source file. But a short cut approach is provided in the format of Macro syntax. To use it, the member name is specified on the SQL parameter of RUNiQRY and is prefixed with an asterisk. The source member must exist in a source file named QSQLMACRO and that file must be in a library on the library list.

There are a number of macros shipped with SQL iQuery (see below) they are stored in the QIQMACRO source file in library IQUERY.

If the macro name does not exist in QSQLMACRO on the library list, then QIQMACRO in library IQUERY is searched for the macro name. This means user-written macro names will override those supplied with the SQL iQuery product.

For example, the source member named DEMO in source file QIQMACRO contains: SELECT * FROM QIWS.QCUSTCDT; along with a few SQL iQuery Script statements. To run this macro, the following RUNIQRY command could be used:

RUNIQRY *DEMO

When this macro is run, SQL iQuery first checks for the macro name as a member in file QSQLMACRO on the library list. If it does not locate a member with that name, it then searches source file QIQMACRO in the SQL iQuery product library (IQUERY) for the member.

Basically this allows users to override the shipped Macro names with their own custom macro, without changing those shipped with SQL iQuery.

SQL iQuery Macros

The SQL iQuery product ships with the following Macros. Some are for testing/debugging purposes, but most are for daily use.

To use a macro, specify the Macro name with a leading asterisk. For example:

RUNiQRY *HIST

This runs the HIST macro and sends the output to the display (by default).

Another macro that I use frequently is the *MCHINFO (Machine Info) macro. It displays the system serial number, machine type, model number, processor group, feature code, and IBM i vrm all in one place.

Note: You can scroll through this table using your mouse roller/scroll wheel. Oh, and FYI, this HTML Scrolling Table is included in SQL iQuery at no additional cost.

Cozzi SQL iQuery (2COZ-IQ4) Macro List
iQuery Macros are evoked by running:
RUNiQRY *macroName e.g., RUNIQRY *ACTJOBS
Macro
Name
Macro
Description
71 records retrieved.
ACTJOB List Active Jobs (similar to WRKACTJOB)
ALLOBJ List Users with *ALLOBJ authority
ALLUSR List All User Profiles
CACHE Display Cache Batteries status
CACHEBAT Display Cache Batteries status (see CACHE macro)
CCSID Log the CCSID values for "this" job
CHKDUPOBJ List Duplicate objects for 2 different libraries
CMDLIST List Command Definition Information
COMMENTS Add Comments to SQL iQuery UDF/UDTFs (run once)
COZRPGFREEList *PGM/*SRVPGM using legacy RPGFREE *SRVPGM
COZTOOLS List Programs that bind to COZTOOLS (long running)
COZXFUNC List SQL iQuery UDF/UDTF not installed in STD Libs
COZXREF List PGMs that bind to any COZZI Libs (long run)
CRTIQLOG Create SQL iQuery log database table (run once)
DB2PTF DB2 Group PTF Level
DEMO SQL iQuery Demo using QIWS.QCUSTCDT
DFTPWD Check for Users Potentially with Default Password
DMGOBJ Damaged Objects Report
DROPIQUDF Drop iQuery Func not in iQuery or related libs
DSK Similar to WRKDSKSTS but with Mirroring Info
DSPJRN Display Journal
FUNC Display SQL iQuery Functions List
GRPPRF Group Profile Membership list
HIST Local IBM i History Log (last 24 hours)
IBMBLOG IBM Db2 for i Blog Article Links
INTERACT Display All Interactive Jobs
IQUERY List *PGM/*SRVPGM using SQL iQuery product library
IQVER Display the current SQL iQuery Ver
IQVRM Display the current SQL iQuery Ver
JOBATTR Job Attributes
JOBCMD List Commands Run in Job SETVAR((JOB ...))
JOBD List job descriptions
JOBLOG Joblog table Function QSYS2.JOBLOG_INFO(...)
JOBLOGEX Joblog table Function QSYS2.JOBLOG_INFO(...)
JOBSCD Check Job Scheduler Entry Last Submitted Status
JOBSCDE List Job Scheduler Entries
JRNDBF List User *FILE's being Journalled (long running)
KEYFLD Key Fields List SETVAR((FILE MYFILE) (LIB MYLIB))
LASTIPL Display last system start date/time (last IPL)
LASTUSED Program Last Used Date/Time -- iQuery OBJ_LIST
LIBL Current Job''s Library List
LIBSIZE Library Sizes
LICPGM Installed License Programs (a better view)
LOG SQL iQuery Log File query SETVAR((USER xxxxx))
MACROS SQL iQuery UDTF/UDF/Procs installed system wide
MBRLIST MBRL SETVAR((LIB ll) (FILE ff) (MBR mm) (TEXT tt))
MCHINFO Machine Type,Model,Proc Group,Feature Code,Serial
MSGW List Jobs in MSGW (Message Wait) Status
OBJLIST Object list using IBM's Object Statistics UDTF
OBJSTRUCT Exploded Object List (*MODULE and *SRVPGM list)
OUTQ List OUTQ (output queues) with SPOOL Files
PTFBKPLVL Back-level Group PTFs
PTFGRP PTF Group Levels
RPGFREE Search for COZTOOLS/RPGFREE *SRVPGM Where Used
SIGNON SQL iQuery macro to list recent User Sign On/Off
SPCVAL Special Values Query
SPLF List my spool files
SQLINFO List Program SQL Statements used in programs
STACK Display Call Stack
SYS System Information
SYSVAL List all System Values and their Value
TCPIP TCP/IP Info
TOPHOGS Top Storage Hogs
TOPLIMITS Top 3 Consumption Points
USER Alt version of *USRPRF macro
USERS Alt version of *USRPRF macro
USRGRP List each User Profile's Group Profiles
USRPRF List Non-IBM User Profiles
VER Abbr version of *VERSION Macro
VERSION Display IBM i VxRyMz & TR level along w/iQuery ver
VRM Abbr version of *VERSION Macro

Copyright © 2018 Cozzi Productions, Inc. All Rights Reserved.