Was this helpful?
length_check Routine--Check for Valid Length
The length_check routine checks that the specified length for the data type is valid. If the specified length is user specified, the routine returns the corresponding internal length. If the length is not user specified, it returns a user length corresponding to internal length.
Place the address of this routine in the dtd_lenchk_addr field of the IIADD_DT_DFN structure.
If the value of user_specified is not 0, then the length is a value specified by a user or user program-for example, 4 if user typed 'varchar(4)'. If the value of user_specified is 0, then the length is the internal length, for example, 6 for varchar(4).
If you specify result_dv, then it must be set to the valid length regardless of the success or failure of the routine. If user_specified is non-zero, then result_dv must specify the corresponding internal length. Conversely, if user-specified is zero, then result_dv must specify the user length corresponding to the provided internal length.
Inputs
The inputs for this function are:
scb
Pointer to SCB.
user_specified
0 if not user specified, non-zero otherwise.
dv
Pointer to datavalue to be checked. If user_specified is non-zero, then the length field refers to the length specified by the user. Otherwise, it refers to an internal length.
result_dv
Pointer to an II_DATA_VALUE into which to place the correct length. This parameter can be NULL (0). When this is the case, simply return success or error status.
Outputs
The outputs for this function are:
result_dv->db_length
Contains the valid length. If the user_specified field is non-zero, this field must be set to the corresponding internal length. If the user_specified field is 0, then set this to the corresponding user length.
Returns
II_STATUS
Last modified date: 01/30/2023