-138   THE SECOND OR THIRD ARGUMENT OF THE SUBSTR OR SUBSTRING FUNCTION IS OUT OF RANGE

Explanation

One of the following conditions exists:
  • The value of the second argument of the SUBSTR or SUBSTRING function is less than 1 or greater than M.
  • The value of the third argument of the SUBSTR or SUBSTRING function is an integer constant 0 or greater than M-N+1.
M is the length of the first argument if it is of fixed-length, or, M is the maximum length of the first argument if it is of varying-length. N is the value of the second argument.

System action

The statement cannot be processed.

Programmer response

Ensure that the second and third arguments of the SUBSTR or SUBSTRING function have legal values according the rules listed in the Explanation.

SQLSTATE

22011