CHECK Command [ HP ALLBASE/4GL Developer Reference Manual Vol. 2 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 2
CHECK Command
The CHECK command matches the contents of a field against a validation
table or a series of contiguous fields in an indexed (KSAM) file record.
The command returns the matched position in the table or file record to
the *PASS communication area field.
You can only use the CHECK command with KSAM data files. You cannot use
the CHECK command with serial data files, HP TurboIMAGE/iX data sets, HP
ALLBASE/SQL tables, or select lists.
Formats
{*TABLE=table }
CHECK data_ref {file_ref [*INDEX=index_name]}
{*KEY=key[entries_field_name]}
Window
Parameters
data_ref
The value to be checked against the table or field in the file record.
It can be one of the following:
* Variable or calculated item.
* Screen field reference.
* Scratch-pad field reference.
* File record field reference.
* Work area field reference.
table
If checking against a table, this must be the name of a validation table.
file_ref
If checking against a file record which contains a series of contiguous
fields, this should be the name of the file, optionally followed by a
record name.
If you don't specify a record name, HP ALLBASE/4GL uses the default
record for the file.
index_name
If checking against a file, this parameter allows you to specify the name
of the index to be used to access the file. The index name must be the
name of a field specification defined as a key field on the default
record layout for the files. You can also specify the index by entering
the number of an index for the file in the *INDEX= field.
If you don't specify an index name, HP ALLBASE/4GL accesses the file
according to the index specified by the current value of *INDEXNO.
key
If checking against a file, this field is mandatory. It can be one of
the following:
* Literal.
* Alphanumeric constant.
* Variable or calculated item.
* Screen field reference.
* Scratch-pad field reference.
* File record field reference.
* Work area field reference.
* Non-numeric communication area field.
entries_field_name
This field is optional and, if specified, should be a file record field
reference.
Description
The CHECK command matches the contents of data_ref against either:
* A validation table, or
* A series of contiguous fields in a specified file record.
If a match occurs, the CHECK command places the matching position number
into the *PASS communication area field. Only the first matching
position is reported.
If no match occurs, the CHECK command places a zero in the *PASS field.
You can then use the content of *PASS as desired. For example, it could
be used to execute a specific step within a SELECT command.
If checking against a table, *TABLE=table specifies the validation table
to be searched. This table must be defined on the dictionary validation
table definition screen.
If checking against a series of fields in an indexed (KSAM) file record,
*KEY=key defines the key of the file record to be retrieved before
performing the search.
If you don't use the *INDEX = index_name argument, HP ALLBASE/4GL uses
the current value of *INDEXNO to determine the key number for the file
search. If the index allows duplicate key values, only the first
occurrence is used. If the required record can't be accessed, the CHECK
command places a zero in *PASS (no match occurred).
When checking against fields in a file record, HP ALLBASE/4GL expects the
record to contain:
* A field containing a number equal to the number of fields to be
searched.
- immediately followed by:
* A series of contiguous fields, all of the same length, containing
the data to be searched.
Unless you specify the optional parameter entries_field_name, these
fields must occur at the start of the record and they must always occur
together in the relationship defined above.
The optional parameter entries_field_name specifies the name of a field
in the file record defined by *KEY. This field must contain a number
equal to the number of fields to be searched. The fields to be searched
must immediately follow this field, and must be contiguous.
Example 1
CHECK * trans_code *KEY=*S01
This command accesses the file trans_code using the contents of screen
field number 1 as the key. When HP ALLBASE/4GL reads the specified
record, it assumes that the first field contains a number equal to the
number of fields to be searched. HP ALLBASE/4GL then searches those
fields for a match against the contents of the current screen field. If
a match occurs, the CHECK command places the number of the matching field
into *PASS. If no match occurs, the CHECK command places the digit zero
into *PASS.
Example 2
CHECK V-state *TABLE=valid_states
This command checks the contents of variable state against the validation
table valid_states.
MPE/iX 5.0 Documentation