Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
JeffC wrote:
> 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.
As others accurately diagnosed, what the engine taketh away, the tool
putteth back. Don't use DB-Access for this. Use SQLCMD from the IIUG
Software Archive:
$ userid=$(sqlcmd -d $DB "select trim(trailing ' ' from userid) asuserid from table where userid = 'a1abcdef'")
The reverse numeric sort in your version is curious - pourquoi? And
why not simply put an ORDER BY userid DESC in the SELECT?
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.