z/OS ISPF Services Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


TBQUERY—obtain table information

z/OS ISPF Services Guide
SC19-3626-00

The TBQUERY service returns information about a specified table, which must have been opened (TBOPEN) by the current user before invoking this service. This information can be obtained:
  • The number of key fields and their names
  • The number of all other columns and their names
  • The number of rows and the current row position
  • The sort arguments in the last invocation of TBSORT
  • Details of the last invocation of TBSARG

All the parameters except for table-name are optional. If all of the optional parameters are omitted, TBQUERY simply validates the existence of an open table.

Command invocation format

Read syntax diagramSkip visual syntax diagram
>>-ISPEXEC--TBQUERY--table-name--+----------------+------------->
                                 '-KEYS(key-name)-'   

>--+-----------------+--+---------------------+----------------->
   '-NAMES(var-name)-'  '-ROWNUM(rownum-name)-'   

>--+---------------------+--+-----------------------+----------->
   '-KEYNUM(keynum-name)-'  '-NAMENUM(namenum-name)-'   

>--+--------------------+--+--------------------+--------------->
   '-POSITION(crp-name)-'  '-SORTFLDS(srt-name)-'   

>--+--------------------+--+---------------------+-------------->
   '-SARGLIST(lst-name)-'  '-SARGCOND(cond-name)-'   

>--+-------------------+---------------------------------------><
   '-SARGDIR(dir-name)-'   

Call invocation format

Read syntax diagramSkip visual syntax diagram
>>-CALL--ISPEXEC--(buf-len,--buffer);--------------------------><

or

Read syntax diagramSkip visual syntax diagram
>>-CALL--ISPLINK--('TBQUERYb'--,--table-name--,-+-key-name-+---->
                                                '-'b'------'   

>--,-+-var-name-+--,-+-rownum-name-+--,-+-keynum-name-+--------->
     '-'b'------'    '-'b'---------'    '-'b'---------'   

>--,-+-namenum-name-+--,-+-crp-name-+--,-+-srt-name-+----------->
     '-'b'----------'    '-'b'------'    '-'b'------'   

>--,-+-lst-name-+--,-+-cond-name-+--,-+-dir-name-+--);---------><
     '-'b'------'    '-'b'-------'    '-'b'------'       

Parameters

table-name
Specifies the name of the table for which information is desired.
key-name
Specifies the name of a variable into which a list of key variable names contained in the table will be stored. A list that is not null will be enclosed in parentheses, and the names within the list will be separated by a blank. If no key variables are defined for the table, the key-name variable is set to null.
var-name
Specifies the name of a variable into which a list of variable names in the table, specified with the NAMES keyword when the table was created, will be stored. The list will be enclosed in parentheses, and the names within a list that is not null will be separated by a blank. If no name variables are defined for the table, the var-name variable is set to null.
rownum-name
Specifies the name of a variable in which the number of rows contained in the table will be stored.
keynum-name
Specifies the name of a variable in which the number of key variables contained in the table will be stored.
namenum-name
Specifies the name of a variable in which the number of variables in the table specified with the NAMES keyword when the table was created will be stored.
crp-name
Specifies the name of a variable in which the row number pointed to by the CRP is to be stored. If the CRP is positioned to TOP, the row number returned is zero.
srt-name
Returns the sort arguments as they were presented to TBSORT. If no sort is active for the table then the srt-name variable is set to null.
lst-name
Returns the name-list that was last presented to the TBSARG service ARGLIST parameter. If ARGLIST is not currently active then lst-name variable is set to null.
cond-name
Returns the list of name-cond pairs that was last presented to the TBSARG service NAMECOND parameter.
dir-name
Returns the current direction of the search (NEXT or PREVIOUS) established for TBSCAN.
buf-len
Specifies a fullword fixed binary integer containing the length of "buffer".
buffer
Specifies a buffer containing the name of the service and its parameters in the same form as they would appear in an ISPEXEC call for a command procedure.

Return codes

These return codes are possible:
 0
Normal completion.
12
Table is not open.
16
Not all keys or names were returned because insufficient space was provided.
20
Severe error.

Example

For the keyed table TELBOOK:
  • In dialog variable QKEYS, store the names of key variables.
  • In dialog variable QNAMES, store the names of non-key variables.
  • In dialog variable QROWS, store the number of rows.
ISPEXEC TBQUERY TELBOOK KEYS(QKEYS) NAMES(QNAMES) ROWNUM(QROWS)
Set the program variable BUFFER to contain:
TBQUERY TELBOOK KEYS(QKEYS) NAMES(QNAMES) ROWNUM(QROWS)
Set program variable BUFLEN to the length of the variable BUFFER. Issue the command:
CALL ISPEXEC (BUFLEN, BUFFER);

or alternately

CALL ISPLINK ('TBQUERY ','TELBOOK ',
              'QKEYS ','QNAMES ','QROWS ');

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014