Re: TRIM Function does not remove trailing spaces from string
Posted in 2003
In message <c703eed2.0306190725.c49721a@posting.google.com>, JeffC
<gninnacj@netscape.net> writes
>Hi,
>
>When using the following the trailing spaces are not removed from
>the string. Why does this not work properly?
>
>$ userid=$(echo "select trim(trailing ' ' from userid) as userid from
>table where userid = 'a1abcdef'" | dbaccess $DB 2>/dev/null | grep -vi
>user | sort -nr)
>$ echo "[${userid}]"
>[a1abcdef ]
> ^^^^>The spaces have not been trimmed in the result.
>
>Regards,
>Jeff
I guess it's because dbaccess is trying to pretty-print the output and
line up the text under the column headings. The 'trim' is working OK,
it's just that spaces are getting added later when the data is output.
I think that if you want to avoid this you need to use 'unload', as
'output to pipe cat select...' exhibits the same behaviour.
Or if you're using ksh (or similar) echo "[${userid%%+( )}]"
--
Andrew Lennard andy@kontron.demon.co.uk