SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Functions and Expressions
HP NonStop SQL/MX Reference Manual540440-003
9-154
TRIM Function
TRIM Function
The TRIM function removes leading and trailing characters from a character string.
trim-type
specifies whether characters are to be trimmed from the leading end (LEADING),
trailing end (TRAILING), or both ends (BOTH) of trim-source. If you omit trim-
type, the default is BOTH.
trim_char
is an SQL character value expression and specifies the character to be trimmed
from trim-source. trim_char has a maximum length of 1. If you omit
trim_char, SQL trims blanks (' ') from trim-source.
trim-source
is an SQL character value expression and specifies the string from which to trim
characters. See Character Value Expressions on page 6-37.
Considerations for TRIM
Result of TRIM
The result is always of type VARCHAR, with maximum length equal to the fixed length
or maximum variable length of trim-source. If the source character string is an
upshifts CHAR or VARCHAR string, the result is an upshifts VARCHAR type.
Examples of TRIM
Return 'Robert':
TRIM (' Robert ')
The EMPLOYEE table defines FIRST_NAME as CHAR(15) and LAST_NAME as
CHAR(20). This expression uses the TRIM function to return the value 'Robert
Smith' without extra blanks:
TRIM (first_name) || ' ' || TRIM (last_name)
TRIM ([[trim-type] [trim-char] FROM] trim-source)
trim-type is:
LEADING | TRAILING | BOTH