Field-encoding (function code 0)

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

• Parameter 1
Input - A small (2 byte) integer that describes the function to be performed (0 - field-encoding).
• 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
Input – Data to be encoded.

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 5
Input - A structure described by sqlfpParameterDescription_T containing the encoded data attributes.
• Parameter 6
Output – Location to place the encoded data.

If the encoded value is a varying-length string, the first 2 bytes must contain the length. If the encoded 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 7
Input/Output - The SQLSTATE (character(5)).
• Parameter 8
Input/Output - The message text area (varchar(1000)).
• Parameter 9
Input - Reserved.

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.