Specifies that SQL compares at run time the data type, length,
and scale of the descriptor for an actual parameter to what was
declared for the procedure parameter in the SQL module. If the
two do not match, SQL returns an error. The CHECK clause works
only with parameters passed by descriptor from the calling host
language module.
Because there is no connection between an SQL module and a
calling host language program module when they are compiled,
there is no way for SQL to check for agreement between formal
parameter declarations and actual parameters in calls to the
module. The CHECK clause provides a way to do such checking when
the program runs.
If a formal parameter declaration does not specify the CHECK
clause, SQL assumes that procedure and calling parameters agree.
If they do not, programs can give unpredictable results. However,
you may choose not to use the CHECK clause because:
o The CHECK clause is not part of ANSI-standard SQL.
o There is a minor performance penalty for SQL to check
parameters at run time.
o Using CHECK can make host programs more complicated.
The CHECK clause follows these rules in comparing formal
parameters with call parameters:
o If a formal parameter is TIMESTAMP data type, the CHECK clause
accepts any corresponding actual parameter that is 8 bytes
long.
o If the language is C and the formal parameter is CHAR
data type, the CHECK clause expects the descriptor to be
1 byte longer than the number of characters in the formal
parameter. This occurs because character strings in C include
a terminator character (they are in ASCIZ format) that is not
included in the length of the formal parameter declaration.
When you retrieve data definitions from the dictionary,
however, you can change the default interpretation of
character data by specifying FIXED or NULL TERMINATED
CHARACTERS in the record-type clause of the FROM path-name
clause.
o The CHECK clause supports dynamic string descriptors (CLASS_D)
in BASIC for procedure parameters declared with the CHARACTER
data type. However, the CHECK clause does not compare the
length of the descriptor with the length of the procedure
parameter because the buffer to receive the data is allocated
at run time.
o If the formal parameter is VARCHAR data type, the descriptor
that the CHECK clause accepts depends on the language.
- If the language is PL/I or Pascal (languages that support
varying character data type), the descriptor must be a
varying string (CLASS_VS) descriptor, the data type must be
varying text, and the length must be the same as the length
of the formal parameter declaration.
- If the language is not PL/I or Pascal, the CHECK clause
accepts a varying string descriptor as in the preceding
paragraph, or a fixed-length (CLASS_S) or unspecified
(DTYPE_Z) descriptor with data type of text and a length
2 bytes longer than the length of the formal parameter
declaration.
For more detail on the different types of OpenVMS argument
descriptors, see the OpenVMS programming documentation.