RTRIM
The RTRIM
function removes from the right end of Expression1
all of the characters contained in Expression2
. TimesTen scans Expression1
backward from its last character and removes all characters that appear in Expression2
until reaching a character not in Expression2
and then returns the result.
SQL syntax
RTRIM (Expression1
[,Expression2
])
Parameters
RTRIM
has the parameters:
Parameter | Description |
---|---|
|
The |
|
Optional expression used for trimming |
Description
-
If
Expression1
is of typeCHAR
orVARCHAR2
, the data type returned isVARCHAR2
. IfExpression1
is of typeNCHAR
orNVARCHAR2
, the data type returned isNVARCHAR2
. IfExpression1
is aCLOB
orNCLOB
, the data type returned is the same as the LOB data type provided. The returned data type length is equal to the data type length ofExpression1
. -
If
Expression1
is a data type defined withCHAR
length semantics, the returned length is expressed inCHAR
length semantics. -
If either
Expression1
orExpression2
isNULL
, the result isNULL
. -
You can specify
TT_CHAR
,TT_VARCHAR
,TT_NCHAR
, andTT_NVARCHAR
forExpression1
andExpression2
. IfExpression1
is of typeTT_CHAR
orTT_VARCHAR
, the data type returned isTT_VARCHAR
. IfExpression1
is of typeTT_NCHAR
orTT_NVARCHAR
, the data type returned isTT_NVARCHAR
. -
If
Expression1
is of typeCHAR
orVARCHAR2
andExpression2
is of typeNCHAR
orNVARCHAR2
, thenExpression2
is demoted toCHAR
orVARCHAR2
beforeRTRIM
is invoked. The conversion ofExpression2
could be lost. If the trim character ofExpression2
is not in the database character set, then the query may produce unexpected results. -
For
CHAR
,VARCHAR2
,NCHAR
,NVARCHAR2
,CLOB
andNCLOB
types:-
If all the characters in
Expression1
are removed by theRTRIM
function, the result isNULL
.
-
-
For
TT_CHAR
,TT_VARCHAR
,TT_NCHAR
andTT_NVARCHAR
types:-
If all the characters in
Expression1
are removed by theRTRIM
function, the result is the empty string.
-
Examples
The following example trims the trailing spaces from col1
in table rtrimtest
.
Command> CREATE TABLE rtrimtest (col1 VARCHAR2 (25)); Command> INSERT INTO rtrimtest VALUES ('abc '); 1 row inserted. Command> SELECT * FROM rtrimtest; < abc > 1 row found. Command> SELECT RTRIM (col1) FROM rtrimtest; < abc > 1 row found.
Call the RTRIM
function to remove right-most 'x'
and 'y'
from string. RTRIM
removes individual occurrences of 'x'
and 'y'
, not pattern 'xy'
.
Command> SELECT RTRIM ('RTRIM Examplexxxyyyxyxy', 'xy') FROM dual; < RTRIM Example > 1 row found.
Call RTRIM
to remove all characters from Expression1
. In the first example, the data type is CHAR
, so NULL
is returned. In the second example, the data type is TT_CHAR
, so the empty string is returned.
Command> CREATE TABLE rtrimtest (col1 CHAR (4), col2 TT_CHAR (4)); Command> INSERT INTO rtrimtest VALUES ('BBBA', 'BBBA'); 1 row inserted. Command> SELECT RTRIM (col1, 'AB') FROM rtrimtest; < <NULL> > 1 row found. Command> SELECT RTRIM (col2, 'AB') FROM rtrimtest; < > 1 row found.