Example: Using TRIM Functions

Teradata Vantage™ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

The following table illustrates several more complicated TRIM functions.

Function Result
SELECT TRIM(LEADING 'a' FROM 'aaabcd'); 'bcd'
CREATE TABLE t2

  (i1 INTEGER, c1 CHAR(6), c2 CHAR(1));

INSERT t2 (1, 'aaabcd', 'a');

SELECT TRIM(LEADING c2 FROM c1) FROM t2;

'bcd'
CREATE TABLE t3

  (i1 INTEGER, c1 CHAR(6) CHAR SET UNICODE);

INSERT t3 (1, _Unicode '006100610061006200630064'XC);

SELECT TRIM(LEADING _Unicode '0061'XC FROM t3.c1);

'bcd'
SELECT TRIM(_Unicode 'ΔΔ abc ΔΔΔ '); 'abc '
SELECT TRIM(_Unicode 'ΔΔ abc ΔΔ Δ '); 'abc ΔΔ '

Δ (GRAPHIC pad) is not removed.

CREATE TABLE t1

  (c1 CHARACTER(6) CHARACTER SET GRAPHIC);

INSERT t1 (_Graphic 'abc ΔΔ ');

SELECT TRIM(c1) from t1;

'abc '

Δ (GRAPHIC pad) is removed because the operand of the TRIM function is of type GRAPHIC.