RIGHT

Click to skip syntax diagram
Read syntax diagramSkip visual syntax diagram>>-RIGHT--(--expression--,--integer--)-------------------------><
 

The RIGHT function returns the rightmost integer characters of expression.

If expression is a character string, the result is a character string, and each character is one byte. If expression is a graphic string, the result is a graphic string, and each character is a DBCS or Unicode graphic character. If expression is a binary string, the result is a binary string, and each character is one byte.

expression
An expression that specifies the string from which the result is derived. The string must be a built-in numeric or string expression. A numeric argument is cast to a character string before evaluating the function. For more information on converting numeric to a character string, see VARCHAR.

A substring of expression is zero or more contiguous characters of expression. If expression is a graphic string, a character is a DBCS or Unicode graphic character. If expression is a character string or binary string, a character is a byte.50

integer
An expression that returns a built-in integer data type. The integer specifies the length of the result. integer must be greater than or equal to 0 and less than or equal to n, where n is the length attribute of expression.

The expression is effectively padded on the right with the necessary number of blank characters (or hexadecimal zeroes for binary strings) so that the specified substring of expression always exists.

The result of the function is a varying-length string with a length attribute that is the same as the length attribute of expression and a data type that depends on the data type of expression:

Data type of expression Data type of the Result
CHAR or VARCHAR VARCHAR
CLOB CLOB
GRAPHIC or VARGRAPHIC VARGRAPHIC
DBCLOB DBCLOB
BINARY or VARBINARY VARBINARY
BLOB BLOB

The actual length of the result is integer.

If any argument can be null, the result can be null; if any argument is null, the result is the null value.

The CCSID of the result is the same as that of expression.

Example


50.
The RIGHT function accepts mixed data strings. However, because RIGHT operates on a strict byte-count basis, the result will not necessarily be a properly formed mixed data string.