Easy way to view and select records with RUNQRY

This post may be a bit elementary to some but I have noticed that some system i users could use a quicker, simpler method to view and select data from a file (physical or logical). When the need is for a quick peek and verification and there is no need to save the query or the resulting records it is very hard to beat the RUNQRY command.

The obvious short-comings of DSPPFM for displaying file data are that it does not unpack numeric data so the search feature is only useful if the field you are checking is alphanumeric. The DSPPFM search bar is also case-sensitive. IBM suggests that there are some advantages in using STRQMQRY instead of RUNQRY when a query definition exists. However I think RUNQRY is preferable when you simply want to check for the existence, the name of a field, or the size of a field and don't want or need to create or save a QRYDFN.

You may have run across RUNQRY in some older CL programs where the command is used to run an existing query, usually to print some reports or build some work files. However, the real power comes from using the command interactively when saving the query is unnecessary (which is normally the case when you just want a quick search).

Any confusion about RUNQRY can be cleared up with a few short explanations. First, using STRQRY is not required to select records (nor is STRSQL). RUNQRY provides the same select/omit logic. If you have ever used STRQRY you will already be familiar with the RUNQRY selection screen. The RUNQRY command accepts a parameter for the name of the query and *NONE is a valid option. This parameter can also be expressed as a short-hand *N. So the command becomes;

RUNQRY *N  file-name

Simple right? The real benefit is evident when prompting this command and setting the RCDSLT (record select) to *YES. The standard query selection appears.

RUNQRY *N  file-name {press F4}

Once the command is run and records are selected the user can F12/cancel and return to and change the selection criteria. The command can be used to select and unpack numeric data. The command leaves absolutely no footprint and, unlike some file editors (of which I am also a big fan) there is no risk of any unwanted data updates. The command does have a *PRINT parameter which is handy on rare occasions. Formatting query output, joining files, and sorting are more likely situations where you would normally want to save the query (object type *QRYDFN) so STRQRY is indicated.

In summary, the strength of the interactive RUNQRY command is in it's simplicity and speed. RUNQRY is a great tool for any programmer and can be used as a companion, not a replacement, for saved queries, file editors, and your application software.

All apologies if you find this as 'blindingly obvious' but I thought the information needed to be published and may help someone who is struggling to operate faster and more efficiently (aren't we all?).