RPAD
Converts a string to a specified length by adding blanks or characters to the end of the string.
Syntax
RPAD( first_string, length [,second_string] )
The following table describes the arguments for this command:
Argument | Required/ Optional | Description |
---|
first_string | Required | Any string value. The strings you want to change. You can enter any valid transformation expression. |
length | Required | Must be a positive integer literal. Specifies the length you want each string to be. |
second_string | Optional | Any string value. Passes the string you want to append to the right-side of the first_string values. Enclose the characters you want to add to the end of the string within single quotation marks, for example, 'abc'. This argument is case sensitive. If you omit the second string, the function pads the end of the first string with blanks. |
Return Value
String of the specified length.
NULL if a value passed to the function is NULL or if length is a negative number.
Examples
The following expression returns the item name with a length of 16 characters, appending the string '.' to the end of each item name:
RPAD( ITEM_NAME, 16, '.')
ITEM_NAME | RETURN VALUE |
---|
Flashlight | Flashlight...... |
Compass | Compass......... |
Regulator System | Regulator System |
Safety Knife | Safety Knife.... |
RPAD counts the length from left to right. So, if the first string is longer than the length, RPAD truncates the string from right to left. For example, RPAD(‘alphabetical’, 5, ‘x’) would return the string ‘alpha’. RPAD uses a partial part of the second_string when necessary.
The following expression returns the item name with a length of 16 characters, appending the string ‘*..*’ to the end of each item name:
RPAD( ITEM_NAME, 16, '*..*' )
ITEM_NAME | RETURN VALUE |
---|
Flashlight | Flashlight*..**. |
Compass | Compass*..**..** |
Regulator System | Regulator System |
Safety Knife | Safety Knife*..* |