Field-decoding (function code 4)

The input provided to the field-decoding operation, and the output required, are as follows:

• Parameter 1
Input - A small (2 byte) integer that describes the function to be performed (4 - field-decoding).
• Parameter 2
Input - A structure that defines the modified field procedure parameter value list (FPPVL).
• Parameter 3
Input - A structure described by sqlfpParameterDescription_T containing the decoded data attributes.
• Parameter 4
Output – Location to place the decoded data.

If the decoded value is a varying-length string, the first 2 bytes must contain the length. If the decoded value is a LOB or XML, then the first 4 bytes must contain the length. If the value is numeric, the internal numeric representation of the data. If a datetime value, the value must be in *ISO format.

• Parameter 5
Input - A structure described by sqlfpParameterDescription_T containing the encoded data attributes.
• Parameter 6
Input - encoded data

If the value is a varying-length string, the first 2 bytes contains its length. If the value is a LOB or XML, then the first 4 bytes contains the length. If the value is numeric, the internal numeric representation of the data. If a datetime value, the value is in *ISO format.

• Parameter 7
Input/Output - The SQLSTATE (character(5)).
• Parameter 8
Input/Output - The message text area (varchar(1000)).
• Parameter 9
Input - Indicates that the caller is a system function that requires that the data be decoded without masking.

Errors returned by a field procedure result in SQLCODE -681 (SQLSTATE '23507'), which is set in the SQL communication area (SQLCA) and the DB2_RETURNED_SQLCODE and RETURNED_SQLSTATE condition area item of the SQL diagnostics area. The contents of Parameter 7 and 8 are placed into the tokens, in SQLCA, as field SQLERRMT and in the SQL Diagnostic area condition area item MESSAGE_TEXT. If the database manager is unable to invoke the field procedure then SQLCODE -682 (SQLSTATE '57010') is returned.