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
Expression1is of typeCHARorVARCHAR2, the data type returned isVARCHAR2. IfExpression1is of typeNCHARorNVARCHAR2, the data type returned isNVARCHAR2. IfExpression1is aCLOBorNCLOB, 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
Expression1is a data type defined withCHARlength semantics, the returned length is expressed inCHARlength semantics. -
If either
Expression1orExpression2isNULL, the result isNULL. -
You can specify
TT_CHAR,TT_VARCHAR,TT_NCHAR, andTT_NVARCHARforExpression1andExpression2. IfExpression1is of typeTT_CHARorTT_VARCHAR, the data type returned isTT_VARCHAR. IfExpression1is of typeTT_NCHARorTT_NVARCHAR, the data type returned isTT_NVARCHAR. -
If
Expression1is of typeCHARorVARCHAR2andExpression2is of typeNCHARorNVARCHAR2, thenExpression2is demoted toCHARorVARCHAR2beforeLTRIMis invoked. The conversion ofExpression2could be lost. If the trim character ofExpression2is not in the database character set, then the query may produce unexpected results. -
For
CHAR,VARCHAR2,NCHAR,NVARCHAR2,CLOBorNCLOBtypes:-
If all the characters in
Expression1are removed by theLTRIMfunction, the result isNULL.
-
-
For
TT_CHAR,TT_VARCHAR,TT_NCHARandTT_NVARCHARtypes:-
If all the characters in
Expression1are removed by theLTRIMfunction, 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.