LTRIM
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 |
---|---|
|
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
beforeLTRIM
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
orNCLOB
types:-
If all the characters in
Expression1
are removed by theLTRIM
function, the result isNULL
.
-
-
For
TT_CHAR
,TT_VARCHAR
,TT_NCHAR
andTT_NVARCHAR
types:-
If all the characters in
Expression1
are removed by theLTRIM
function, 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.