The Retrieve Key List command retrieves the basic access path
information about a data base file and a list of the key fields with
attributes. The QDBRTVFD API is used to allow faster access to key
field information than using the DSPFD outfile function.
Only a physical or single format logical file may be specified. A
maximum of 120 key fields can be returned.
Each key field is made up of a 30 byte data structure within the 3600
bytes. If less than 120 key fields exist, the remaining portion of
the area will be blank.
The following is typical CL code in a format that is ready to be
copied for RTVKEYLST and how to process the information within the
list:
DCL &KEYLST *CHAR LEN(3600)
DCL &ELEMENT *CHAR LEN(30)
DCL &FLDNAM *CHAR LEN(10)
DCL &FLDTYP *CHAR LEN(1)
DCL &FLDLEN *CHAR LEN(5)
DCL &DGTLEN *CHAR LEN(2)
DCL &DECPOS *CHAR LEN(2)
DCL &KEYSEQ *CHAR LEN(1)
DCL &ALTCOL *CHAR LEN(1)
DCL &NUMSEQ *CHAR LEN(1)
DCL &NXTKEY *DEC LEN(5 0)
.
RTVKEYLST FILE(xxx) KEYLST(&KEYLST)
CHGVAR &NXTKEY -29
LOOP: CHGVAR &NXTKEY (&NXTKEY + 30)
IF (&NXTKEY *LT 360) DO /* Within list */
CHGVAR &KEYINFO %SST(&KEYLST &NXTKEY 30)
IF (&KEYINFO *NE ' ') DO /* Some key */
CHGVAR &FLDNAM %SST(&KEYINFO 1 10)
CHGVAR &FLDTYP %SST(&KEYINFO 11 1)
CHGVAR &FLDLEN %SST(&KEYINFO 12 5)
CHGVAR &DGTLEN %SST(&KEYINFO 17 2)
CHGVAR &DECPOS %SST(&KEYINFO 19 2)
CHGVAR &KEYSEQ %SST(&KEYINFO 21 1)
CHGVAR &ALTCOL %SST(&KEYINFO 22 1)
CHGVAR &NUMSEQ %SST(&KEYINFO 23 1)
/* */
/* Your processing */
/* */
GOTO LOOP
ENDDO /* Some key */
ENDDO /* Within list */
The QDBRTVFD API is used to access the information.
RTVKEYLST escape messages you can monitor for
---------------------------------------------
TAA9892 More than 120 keys in the file
TAA9893 Multi format logical file
Escape messages from based on functions will be re-sent.
Command parameters *CMD
------------------
FILE The qualified name of the file to retrieve the key
list from. The library value defaults to *LIBL.
*CURLIB may also be used.
RTNLIB An optional return variable that will contain the
library name where the file was found. The value
may be helpful if the file is accessed without a
specific library name. If specified, the variable
must be declared as *CHAR LEN(10).
FILETYPE An optional return variable that will contain either
PF of LF for the file type. If specified, the
variable must be declared as *CHAR LEN(2).
TYPE An optional return variable that will contain either
D (data) or S (source) for the type of file. If
specified, the variable must be declared as *CHAR
LEN(1).
ACCPTH An optional return variable that will contain either
K (Keyed) or A (Arrival) for the type of access
path. If specified, the variable must be declared
as *CHAR LEN(1).
ACCPTHTYP An optional return variable that will contain one of
the following:
AR Arrival sequence
KC Keyed with dup keys allowed in FCFO order
FCFO = First changed, first out
KF Keyed with dup keys allowed in FIFO order
KL Keyed with dup keys allowed in LIFO order
KN Keyed with dup keys allowed
The order is not guaranteed
KU Keyed with no dups allowed
EV Embedded vector
If specified, the variable must be declared as *CHAR
LEN(2).
ACCPTHTYPD An optional return variable that will contain a text
description of the ACCPTHTYP field. If specified,
the variable must be declared as *CHAR LEN(50).
SELOMT An optional return variable that will contain either
Y or N for whether the file has select/omit logic
(only valid on logical files). If specified, the
variable must be declared as *CHAR LEN(1).
NBRKEY An optional return variable that will contain the
number of keys specified for a keyed access path.
If specified, the variable must be declared as *DEC
LEN(3 0).
KEYLEN An optional return variable that will contain the
key length used for a keyed access path. If
specified, the variable must be declared as *DEC
LEN(5 0).
ALTCOLSEQ An optional return variable that will contain Y or N
for whether the keyed access path uses an alternate
collating sequence. If specified, the variable must
be declared as *CHAR LEN(1).
KEYLST An optional return variable that will contain a list
of keys. If used, it must be specified as *CHAR
LEN(3600). The variable will be blank for Arrival
Sequence files. Each key is made up of 30 bytes
with the following format (all fields are *CHAR
types):
1 - 10 Field name
11 - 11 Field type (Use the DSPDTATYP tool)
12 - 16 Field length
17 - 18 Digit length (only for numerics)
19 - 20 Decimal positions (only for numerics)
21 - 21 Key sequence (A = Ascend, D = Descend)
22 - 22 Alternate collating sequence (Y or N)
23 - 23 Numeric sequence (only for numerics)
U = Unsigned
A = Absolute value
S = Signed
24 - 30 Reserved
Restrictions
------------
** A physical or single format logical is required.
** A maximum of 120 keys are supported.
** Because the command returns variables, RTVKEYLST may only be
used in a CL program.
Prerequisites
-------------
The following TAA Tools must be on your system:
EDTVAR Edit variable
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
RTVKEYLST *CMD TAADBJB QATTCMD
TAADBJBC *PGM CLP TAADBJBC QATTCL
|