Oracle® TimesTen In-Memory Database SQL Reference Release 11.2.1 Part Number E13070-04 |
|
|
View PDF |
The LTRIM function removes from the left end of Expression1
all of the characters contained in Expression2
. TimesTen begins scanning Expression1
from its first character and removes all characters that appear in Expression2
until reaching a character not in Expression2
and returns the result.
SQL syntax
LTRIM (Expression1 [,Expression2])
Parameters
LTRIM has the parameters:
Parameter | Description |
---|---|
Expression1 |
The CHAR, VARCHAR2, NCHAR or NVARCHAR2 operand or column to be trimmed. If Expression1 is a character literal, then enclose it in single quotes. |
Expression2 |
Optional expression used for trimming Expression1 . If Expression2 is a character literal, then enclose it in single quotes. If you do not specify Expression2 , it defaults to a single blank. Operand or column can be of type CHAR,VARCHAR2, NCHAR, or NVARCHAR2. |
Description
If Expression1
is of type CHAR or VARCHAR2, the data type returned is VARCHAR2. If Expression1
is of type NCHAR or NVARCHAR2, the data type returned is NVARCHAR2. The returned data type length is equal to the data type length of Expression1
.
If Expression1
is a data type defined with CHAR length semantics, the returned length is expressed in CHAR length semantics.
If either Expression1
or Expression2
is NULL, the result is NULL.
You can specify TT_CHAR, TT_VARCHAR, TT_NCHAR, and TT_NVARCHAR for Expression1
and Expression2
. If Expression1
is of type TT_CHAR or TT_VARCHAR, the data type returned is TT_VARCHAR. If Expression1
is of type TT_NCHAR or TT_NVARCHAR, the data type returned is TT_NVARCHAR.
If Expression1
is of type CHAR or VARCHAR2 and Expression2
is of type NCHAR or NVARCHAR2, then Expression2
is demoted to CHAR or VARCHAR2 before LTRIM is invoked. The conversion of Expression2
could be lost. If the trim character of Expression2
is not in the database character set, then the query may produce unexpected results.
For CHAR, VARCHAR2, NCHAR, and NVARCHAR2 types:
If all the characters in Expression1
are removed by the LTRIM function, then the result is NULL.
For TT_CHAR, TT_VARCHAR, TT_NCHAR and TT_NVARCHAR types:
If all the characters in Expression1
are removed by the LTRIM function, then the result is the empty string.
Examples
Call the LTRIM function to remove left-most 'x' and 'y' from string. LTRIM removes individual occurrences of 'x' and 'y' not pattern 'xy'.
Command> SELECT LTRIM ('xxxyyyxyxyLTRIM Example', 'xy') FROM dual; < LTRIM Example > 1 row found.
Call the LTRIM function to remove YYYY-MM-DD from SYSDATE. Call TO_CHAR to convert SYSDATE to VARCHAR2.
Command> SELECT LTRIM (TO_CHAR(SYSDATE), '2007-08-21') FROM dual; < 22:54:39 > 1 row found.
Call LTRIM 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 ltrimtest (col1 CHAR (4), col2 TT_CHAR (4)); Command> INSERT INTO ltrimtest VALUES ('ABBB','ABBB'); 1 row inserted. Command> SELECT LTRIM (col1, 'AB') FROM ltrimtest; < <NULL> > 1 row found. Command> SELECT LTRIM (col2, 'AB') FROM ltrimtest; < > 1 row found.