Function documentationSUBSTR(x,a,b) Locate this document in the navigation structure

 

SUBSTR(x,a,b) is a string function that outputs part of the character string x (string specification of length n). Only expressions that produce an alphanumeric value are permitted as string specification x. LOB values are allowed. If x is a LOB value, you must specify length b of the desired subarea.

a and b are expressions. The value b may not be larger than the column definition for a CHAR column.

SUBSTR(x,a,b)

x, a, b

Result of the SUBSTR(x,a,b) Function

SUBSTR(x,a,b)

Part of the character string x that starts at the ath character and is b characters long.

SUBSTR(x,a)

SUBSTR(x,a,n-a+1) supplies all of the characters in the character string x from the ath character to the last (nth) character.

b is an unsigned integer

SUBSTR(x,a,b)

b can also have a value that is greater than (n-a+1).

b is not an unsigned integer

SUBSTR(x,a,b)

b may not exceed the value (n-a+1) .

b>(n-a+1)

SUBSTR(x,a)

As many blanks (code attribute ASCII, UNICODE) or binary zeros (code attribute BYTE) are appended to the end of this result as are needed to give the result the length b.

x, a or b is a NULL value

NULL value

Example

SQL Tutorial, Functions, Changing character strings