IBM Support

Query/400 - Display all input/output files referenced by a query definition

Question & Answer


Question

Is there a tool that will list all input and output file references made by my Query/400 query definitions?

Cause

Planning upgrade, and trying to identify all input and output files referenced by all query definitions.

Answer

Use Display Program References (DSPPGMREF) with *OUTFILE support


DSPPGMREF PGM(*ALL/*ALL) OUTPUT(*OUTFILE) OBJTYPE(*QRYDFN) OUTFILE(-your library-/-your outfile-)

Once the command completes, you can run a query over the outfile you just created

SELECT WHPNAM, WHLIB, WHFNAM, WHLNAM, WHFUSG
  FROM -your library-/-your outfile-

(or use a . instead of a / as in library.outfile in FROM clause)

where the fields are:

WHPNAM - Query Definition Name
WHLIB - Query Definition Library Name
WHFNAM - Referenced File Name
WHLNAM - Reference File Library Name
WHFUSG - Referenced File Usage:

1 - Input
2 - Output
3 - Input/Output
4 - Update
5 - Input/Update
6 - Output/Update
7 - Input/Output/Update
8 - Not specified
0 - Not available

DSPFFD of the outfile will give you the field names and text descriptions if you wish to craft your own queries.
You can use the WHERE clause to filter out results:

// Find all input file references for query definition TESTQRY in library QGPL:

SELECT WHFNAM, WHLNAM
  FROM -your library-/-your outfile-
 WHERE WHFUSG = 1
   AND WHPNAM = 'TESTQRY'
   AND WHLIB = 'QGPL'

Usage Notes:

V6R1 (SI34166) - Has limited support. It does NOT supply the file usage and does not have outfile support.
V&R1 (SI46908) - PTF supplies the support listed above, but you must run the following program to update the OIR information for file usage:

CALL PGM(QSYS/QQUIWHOI) PARM(-library name-)

The program must be called every time a new query definition is added or query definition changes its file references, or you may see file references of '8' (Not specified).

V7R2 (no PTF necessary) - Any newly created query definitions will have accurate file usage information. However, any *QRYDFN object save/restored from V6R1 or V7R1 may require program QQUIWHOI to be run. This would not need to be ran again, unless the query definitions were re-restored. The object information repository data is stored with the *QRYDFN object. Keep this in mind if you are bringing data forward to V7R2, you may need to call:

CALL PGM(QSYS/QQUIWHOI) PARM(-library name-)


NOTE: There are no plans currently to enhance V6R1 or V7R1


References

DSPPGMREF field definitions

http://www-01.ibm.com/support/docview.wss?uid=nas8N1012565

DSPPGMREF CL Reference

http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/cl/dsppgmref.htm?lang=en
http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_72/cl/dsppgmref.htm?lang=en

Database Programming

http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_71/dbp/rbafodpref.htm

[{"Product":{"code":"SWG60","label":"IBM i"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"DB2 for IBM i","Platform":[{"code":"","label":"iSeries"},{"code":"PF012","label":"IBM i"}],"Version":"Version Independent","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
18 December 2019

UID

nas8N1021173