-171 THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT argument-position OF function-name IS INVALID

Explanation

The data type, the length, or the value of an argument of a scalar function is incorrect.

argument-position
An integer that identifies the position of the incorrect argument in the function invocation.
function-name
The name of the scalar function.

Start of changeThis error can be issued for an attempt to use a feature that requires a higher APPLCOMPAT setting than the current setting. The current APPLCOMPAT setting does not support a feature that was requested.End of change

System action

The statement that contains the function cannot be processed.

Programmer response

Correct the invocation of the function, and reissue the statement.

Problem determination

If the encoding scheme is EBCDIC or ASCII, a possible reason for this error is that a character argument was specified for a built-in function that expects a graphic argument, or a graphic argument was specified for a built-in function that expects a character argument. The UNICODE encoding scheme supports the mixing of character and graphic arguments, but EBCDIC and ASCII do not.

If the function is a string function, this code might be issued if a string unit was required but not specified. The string unit keywords are CODEUNITS16, CODEUNITS32, and OCTETS.

Start of changeThis error is issued when the RID function is invoked with an unexposed name. An exposed name must be used as the argument to the RID function.End of change

Start of changeIf a parameter of the function is optional, the value of the argument-position token for SQLCODE -171 might take into consideration the implicit argument.End of change

For example, suppose that you invoke this function, in which parameter value '12' is invalid:

TRIM('12' FROM '123')

Start of changeThe first argument to the TRIM function, BOTH, is implicitly specified. Therefore, the value of argument-position for parameter value '12' is 2.End of change

SQLSTATE

22546 if the error is encountered for an invalid format for a BSON object; 42815 otherwise.