Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Posts
    78

    Angry Unanswered: CHAR(decimal value) return fixed-length problem, help!

    Hello,

    The CHAR() built-in funtion return the decimal value with number of "0"s padding before the decimal number. Is there any way to get around it, just return the character string type with the decimal number?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2003
    Posts
    33

    Re: CHAR(decimal value) return fixed-length problem, help!

    I have one desperate solution .


    db2 "select replace(ltrim(rtrim(replace(char('00012.4050'),'0' ,' '))),' ','0') from
    sysibm.sysdummy1"

    (You need just take off the rtrim)


    Have fun!



    Originally posted by christine2003
    Hello,

    The CHAR() built-in funtion return the decimal value with number of "0"s padding before the decimal number. Is there any way to get around it, just return the character string type with the decimal number?

    Thanks in advance.
    -r-

  3. #3
    Join Date
    Jul 2003
    Posts
    78

    Re: CHAR(decimal value) return fixed-length problem, help!

    Thank you for your idea! it works! But it is interesting, when I try:

    select char(12.4050) from sysibm.sysdummy1, it returns 12.4050, without any "0" padding before it.

    Thanks a lot.


    Originally posted by raisa
    I have one desperate solution .


    db2 "select replace(ltrim(rtrim(replace(char('00012.4050'),'0' ,' '))),' ','0') from
    sysibm.sysdummy1"

    (You need just take off the rtrim)


    Have fun!

  4. #4
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525

    Re: CHAR(decimal value) return fixed-length problem, help!

    Originally posted by christine2003
    Thank you for your idea! it works! But it is interesting, when I try:

    select char(12.4050) from sysibm.sysdummy1, it returns 12.4050, without any "0" padding before it.

    Thanks a lot.

    Yes but have you tried...

    select char ( decimal (12.4050,12,4) ) from sysibm.sysdummy1

    1
    --------------
    00000012.4050

    1 record(s) selected.

  5. #5
    Join Date
    Jul 2003
    Posts
    78

    Talking Re: CHAR(decimal value) return fixed-length problem, help!

    You are absolutely right. I defined the decimal number (15,2) in my SP. So that's the problem. Thank you so much for your replys.


    Originally posted by Damian Ibbotson
    Yes but have you tried...

    select char ( decimal (12.4050,12,4) ) from sysibm.sysdummy1

    1
    --------------
    00000012.4050

    1 record(s) selected.

Posting Permissions

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