In this post, you’ll learn about the error message -138 the second or third argument of the substr function is out of range in the IBM DB2 database , the reason why it occurs along with the solution to fix it
IBM DB2 Error Message
-138 the second or third argument of the substr function is out of range
Reason for the Error
One of the following conditions exists:� *�� The second argument of the SUBSTR function is less than 1 or greater���� than M.� *�� The third argument of the SUBSTR function is an integer constant 0 or���� an expression whose value is less than 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.
Ensure that the second and third arguments of the SUBSTR function have legal values according the above rules.