Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2011
    Posts
    13

    Unanswered: rtrim not removing trailing spaces

    I'm using DB2 9.7 for AIX and have an odd problem...

    Code:
    SELECT DISTINCT 
    rtrim(A1||':'||A2||'#'||A3||':'||A4||'#'||A3) as SYSTEM 
    from DB2.SYSTEM WHERE VALID = 'Y' AND 
    DATE(atimestamp) <= (CURRENT DATE - 1 MONTH)
    My issue is that the output is:

    Code:
    1
    ---------------------------------
    1234567:ABC#XX:112233#20
    ie, trailing spaces are still present even with adding rtrim in two different places. Anyone have any ideas as to what's going on?

    I'm running it as "db2 -tvf query.sql > output.txt"
    Last edited by rnem170; 11-09-12 at 13:51. Reason: found a bug in my sql so simplified it...

  2. #2
    Join Date
    Nov 2011
    Posts
    334
    hi,
    Where does the SYSTEMINST_KEY column come from?
    any way,
    You can embrace it in a [] to test whether there are spaces :
    select '['||rtrim(SYSTEMINST_KEY)||']' from ALLDATA
    where VALID = 'Y' ORDER BY 1 WITH UR

  3. #3
    Join Date
    Nov 2011
    Posts
    13
    Quote Originally Posted by fengsun2 View Post
    hi,
    Where does the SYSTEMINST_KEY column come from?
    any way,
    You can embrace it in a [] to test whether there are spaces :
    select '['||rtrim(SYSTEM)||']' from ALLDATA
    where VALID = 'Y' ORDER BY 1 WITH UR
    oops, forgot to sanitise that bit of my sql - have corrected it

    It now says:

    1
    -----------------------------------
    [1234567:ABC#XX:112233#20]

    so where are these trailing spaces coming from? It this a magical db2 function.
    Last edited by rnem170; 11-09-12 at 12:09.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •