Default language.

Limited supportBMC provides limited support for this version of the product. As a result, BMC no longer accepts comments in this space. If you encounter problems with the product version or the space, contact BMC Support.BMC recommends upgrading to the latest version of the product. To see documentation for that version, see BMC AMI Load for Db2 13.1.

TRIM


The TRIM function removes blanks or other characters from the end, the beginning, or both ends of a string expression. The data type of the result is the same as the string expression, but in a different format.

TRIM.png

Arguments

The arguments are defined as follows:

stringExpression

Must be one of the following data types:

  • CHAR
  • VARCHAR
  • GRAPHIC
  • VARGRAPHIC
  • BINARY
  • VARBINARY

direction

(Optional) Determines whether characters are removed from the end (TRAILING), the beginning (LEADING), or from both (BOTH) directions of the stringExpression.

Must be one of the following values:

  • (Default)
  • Leading
  • Trailing

trimCharacter

(Optional) A single single-byte character set (SBCS) or double-byte character set (DBCS) character constant in the same data type as stringExpression

When you specify a form other than UX", BX", or X", the utility assumes that the encoding scheme is EBCDIC and converts the encoding scheme of stringExpression. If you omit the trim character constant, the default is the padding character of stringExpression.

The trim character data type must match the string expression data type. Otherwise the function will be rejected with an error.

Important

If either the trimCharacter or the stringExpression is null, the result of the function is null.

Results

The following example shows how to remove a leading 0 and trailing blanks from a string expression:

SELECT TRIM( TRAILING FROM TRIM (LEADING ‘0‘ FROM ‘000001              ’))  FROM SYSIBM.SYSDUMMY1;

The inner TRIM option removes the leading 0s from the string expression, resulting in ‘1              ’ as the new string expression.
The outer TRIM option removes the trailing blanks from the new string expression, resulting in ‘1’.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*