DB2 Version 9.7 for Linux, UNIX, and Windows

LTRIM scalar function

Read syntax diagramSkip visual syntax diagram
>>-LTRIM--(--string-expression--)------------------------------><

The schema is SYSIBM. (The SYSFUN version of this function continues to be available with support for CLOB arguments.)

The LTRIM function removes blanks from the beginning of string-expression.

The expression must return a value that is a built-in CHAR, VARCHAR, GRAPHIC, VARGRAPHIC, numeric, or datetime data type. If the value is not a CHAR, VARCHAR, GRAPHIC, or VARGRAPHIC data type, it is implicitly cast to VARCHAR before evaluating the function.
  • If the argument is a graphic string in a DBCS or EUC database, then the leading double byte blanks are removed.
  • If the argument is a graphic string in a Unicode database, then the leading UCS-2 blanks are removed.
  • Otherwise, the leading single byte blanks are removed.
The result data type of the function is:
  • VARCHAR if the data type of string-expression is VARCHAR or CHAR
  • VARGRAPHIC if the data type of string-expression is VARGRAPHIC or GRAPHIC

The length parameter of the returned type is the same as the length parameter of the argument data type.

The actual length of the result for character strings is the length of string-expression minus the number of bytes removed for blank characters. The actual length of the result for graphic strings is the length (in number of double byte characters) of string-expression minus the number of double byte blank characters removed. If all of the characters are removed, the result is an empty, varying-length string (length is zero).

If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Example:

Assume that host variable HELLO is defined as CHAR(9) and has a value of ' Hello'.
   VALUES LTRIM(:HELLO)

The result is 'Hello'.