Retrieves information about an NDB database.
&NDBINFO dbname { DB | [ FIELD ] { NAME=fieldname | NUMBER=n } }
[ FORMAT=formatname [ FSCOPE={ PROCESS | GLOBAL } ] ]
[ FULL | SHORT ]
The &NDBINFO verb allows an NCL procedure to obtain information about an NDB, including information about the database itself, and information about the fields defined in it.
The information is returned in NCL variables.
Operands:
Specifies the name of the NDB that you wish to retrieve information about, and is a mandatory operand. The NDB must have been previously opened by an &NDBOPEN statement.
Indicates that information about the database itself is to be returned. The information is returned in the following NCL variables:
Indicates that information about the named field is to be returned. If the named field does not exist in the nominated NDB, then &NDBRC is set to 3. The information returned is listed below.
Specifies that information about relative field number n is to be returned. This number must be from 1 to the value returned by an &NDBINFO DB request in &NDBDBNFLDS. The information returned on the field requests is set into NCL variables as shown:
dddddddd ff a b c d e f g h i j k l m n o p q r s
where:
Note: Even non-keyed fields will have a non-zero date set after key statistics collection, but all other fields will be zero.
Numeric, date, and floating point fields are all fixed length-4, 3, and 8 respectively. In this case, all the values except modal count are that value (modal count equals the number of VSAM records. The modal value calculation cannot overflow for key length statistics.
The all-equal key length is the maximum key length, in all cases (including fixed length fields), where all values found had the same prefix. It can range from zero to the maximum key length. (It is used by the scan optimizer in weighing generic and range requests.)
The maximum number of records having any unique value is greater than one for a field defined as KEY=UNIQUE. This is because NDB ALTER OPT=BLDX can tolerate unique key violations during index build, allowing you to correct them later.
FORMAT=formatname indicates that the format formatname, defined on the &NDBFMT statement, is to be used. The nominated format must exist in the nominated scope. PROCESS is the default, and indicates a format defined by the current NCL process. GLOBAL indicates that a format is to be found in the global format pool for the NDB.
If the format does not exist, a response code of 20 is returned. If the format exists, a set of variables is returned, as follows:
Contains the value INPUT if this is an input format (that is, usable on an &NDBGET statement), or the value OUTPUT if this is an output format (for use with &NDBADD or &NDBUPD verbs).
Contains the number of &NDBFMTn NCL variables returned.
Contain strings of blank-separated values that describe either an individual field entry or a link to another record.
If the format is for input use, and the variable describes a return field, it is in the following format:
a b c d e f g h i
where:
If the format is for input use, and the variable describes a link to another record, it is in the following format:
a b c d e f
where:
If the format is for output use, it is in the following format:
a b c d
where:
The order of returned information in these variables agrees with the original format definition in that field for a specific record or link definition. However, the order of field description entries is not necessarily the same as the original format, as generic or range field specifications are expanded out and all fields are returned in internal ID order within a record or link.
The FULL option requests that all information about the field be returned. The SHORT option requests that the only information that is obtained without reading the NDB be returned. The following fields are not returned:
Examples: &NDBINFO
The following example returns information about the NDB called MYNDB in NCL variables &NDBDB... (as described previously).
&NDBINFO MYNDB DB
The next example returns information about the field called 'SURNAME' in MYNDB. The returned information is in NCL variables &NDBFLD... (as described previously).
&NDBINFO MYNDB NAME=SURNAME
The following example returns information about all the fields defined in MYNDB.
&NDBINFO MYNDB DB &I = 1 &DOWHILE &I LE &NDBDBNFLDS &NDBINFO MYNDB NUMBER=&I ... process field definition &I = &I + 1 &DOEND
Notes:
Errors encountered whilst processing the &NDBINFO statement may cause the procedure to terminate, or may just be reflected in the &NDBRC system variable, depending on the setting of &NDBCTL ERROR option.
The nominated NCL variables are not updated if a nonzero response is returned in &NDBRC (for example, named field not found).
The &NDBINFO statement makes it easy to write generalized NCL procedures to manipulate NDBs. The procedures can open any NDB and, by using &NDBINFO statements, build tables of control information for further processing.
In a similar way, a generalized database unload/reload utility is constructed.
Note: See also the NDB CREATE command description in the Online Help.
| Copyright © 2009 CA. All rights reserved. |
|