RTRIM
Purpose
Returns the string argument string1, with its right-most characters removed up to the first character that is not in the string argument string2.
Syntax
where:
Syntax element… |
Specifies… |
TD_SYSFNLIB |
the name of the database where the function is located. |
string1 |
a character string or string expression. |
string2 |
an optional string of characters that will be removed from string1. If string2 is not specified, the default is to use a single space character. |
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Invocation
RTRIM is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.
Argument Types and Rules
Expressions passed to this function must have one of the following data types:
If any of the input arguments are NULL, the function returns NULL.
You can also pass arguments with data types that can be converted to the above types using the implicit data type conversion rules that apply to UDFs.
Note: The UDF implicit type conversion rules are more restrictive than the implicit type conversion rules normally used by Teradata Database. If an argument cannot be converted to the required data type following the UDF implicit conversion rules, it must be explicitly cast.
For details, see “Compatible Types” in SQL External Routine Programming.
Result Type
The result data type and character set are the same as those of the string1 argument. For example, if the string1 argument has a data type of VARCHAR CHARACTER SET UNICODE, the result data type is VARCHAR CHARACTER SET UNICODE.
Example
The following query returns the result 'TURNERyxX'. RTRIM removes the individual occurrences of 'x' and 'y', and it stops removing characters when it encounters 'X' because 'X' is not in the string2 argument.
SELECT RTRIM('TURNERyxXxy,'xy');
Example
The following query returns the result ' RIGHTT TRIM' because the leading spaces are not removed. It stops removing characters when it encounters 'M' because 'M' is not in the string2 argument. Since the string2 argument is not explicitly specified, the default of a single space is used.
SELECT RTRIM(' RIGHTT TRIM ');