Chapter 4: SQL Language Elements
4.9.2.70 RPAD function (extension)
Syntax
RPAD ( char_expression, length [, pad_expression] )
Description
The scalar function RPAD pads the character string corresponding to the first argument on the right with the character string corresponding to the third argument so that after the padding, the length of the result would be equal to the value of the second argument length.
Example
SELECT RPAD (name, 30)
FROM customer ;
SELECT RPAD (name, 30, '.')
FROM customer ;
Notes
The first argument to the function must be of type CHARACTER.
The second argument to the function must be of type INTEGER.
The third argument, if specified, must be of type CHARACTER.
If the third argument is not specified, the default value is a string of length 1 containing one blank.
If L1 is the length of the first argument and L2 is the value of the second argument, then:
- If L1 is less than L2, the number of characters padded is equal to L2 - L1.
- If L1 is equal to L2, no characters are padded and the result string is the same as the first argument.
- If L1 is greater than L2, the result string is equal to the first argument truncated to first L2 characters.
The result is of type CHARACTER.
If the argument expression evaluates to null, the result is null.