Re: Trimming strings in SQL
Posted in 1998
In article <Pine.BSI.4.05L.9810300742310.16325-100000@mail.his.com>,
Darrel Davis <darreld@mail.his.com> wrote:
> Does Informix SQL have any comparable commands
> like Oracle's LTRIM and RTRIM? Is there another
> way to get trimmed strings is SQL. I know about
> 'clipped' in 4GL but we need to be able to do it
> in SQL.
Directly from the manual, such an amazing thing :-)
>>Use the TRIM() function to remove leading or trailing (or both) pad characters
>>from a string. The TRIM() function returns a VARCHAR string that is identical
>>to the character string passed to it, except that any leading or trailing pad
>>characters, if specified, are removed. If no trim specification (LEADING,
>>TRAILING, or BOTH) is specified, then BOTH is assumed. If no trim character
>>value expression is used, a single space is assumed. If either the trim
>>character value expression or the source character value expression evaluates
to null, the
>>result of the trim function is null. The maximum length of the resultant
string
>>must be 255 or less, because the VARCHAR data type supports only
>>255 characters.
>>
>>Some generic uses for the TRIM() function are shown in the following
>>example:
>>SELECT TRIM (c1) FROM tab;
>>SELECT TRIM (TRAILING '#' FROM c1) FROM tab;
>>SELECT TRIM (LEADING FROM c1) FROM tab;
>>UPDATE c1='xyz' FROM tab WHERE LENGTH(TRIM(c1))=5;
>>SELECT c1, TRIM(LEADING '#' FROM TRIM(TRAILING '%' FROM'###abc%%%')) FROM tab;
RTFM Much?
Tony
--
asalerno@monmouth.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own