convert a decimal number into character

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • karanbikash@gmail.com

    convert a decimal number into character

    hi ,
    I have a column with datatype as decimal(31,2) . The data is like
    123456.67 , 7634578.99
    Is it a way to convert the entire number into character . like
    '1232456.67' .

    The output should not be like as below :
    db2 =select char(decimal(BA L_PRINCIPAL,31, 2)) from
    BIKASHK.RPT_BA_ PAD331 where
    integer(Bal_pri ncipal)!=0

    1
    ---------------------------------
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00

    4 record(s) selected.

    Rather It should be

    10025000.00
    10025000.00
    10025000.00
    10025000.00

    For the above 4 rows and it should be 'char' in data type.

    Appreciate your help .
    Best Regards
    Bikash Karan
  • Serge Rielau

    #2
    Re: convert a decimal number into character

    karanbikash@gma il.com wrote:
    hi ,
    I have a column with datatype as decimal(31,2) . The data is like
    123456.67 , 7634578.99
    Is it a way to convert the entire number into character . like
    '1232456.67' .
    >
    The output should not be like as below :
    db2 =select char(decimal(BA L_PRINCIPAL,31, 2)) from
    BIKASHK.RPT_BA_ PAD331 where
    integer(Bal_pri ncipal)!=0
    >
    1
    ---------------------------------
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00
    000000000000000 00000010025000. 00
    >
    4 record(s) selected.
    >
    Rather It should be
    >
    10025000.00
    10025000.00
    10025000.00
    10025000.00
    >
    For the above 4 rows and it should be 'char' in data type.
    Just LTRIM or STRIP the leading 0s



    --
    Serge Rielau
    DB2 Solutions Development
    IBM Toronto Lab

    Comment

    • karanbikash@gmail.com

      #3
      Re: convert a decimal number into character

      On May 7, 5:34 pm, Serge Rielau <srie...@ca.ibm .comwrote:
      karanbik...@gma il.com wrote:
      hi ,
      I have a column with datatype as decimal(31,2) . The data is like
      123456.67  , 7634578.99
      Is it a way to convert the entire number into character . like
      '1232456.67'     .
      >
      The output should not be like as below :
      db2 =select char(decimal(BA L_PRINCIPAL,31, 2)) from
      BIKASHK.RPT_BA_ PAD331 where
       integer(Bal_pri ncipal)!=0
      >
      1
      ---------------------------------
      000000000000000 00000010025000. 00
      000000000000000 00000010025000. 00
      000000000000000 00000010025000. 00
      000000000000000 00000010025000. 00
      >
        4 record(s) selected.
      >
      Rather It should be
      >
      10025000.00
      10025000.00
      10025000.00
      10025000.00
      >
      For the above 4 rows and it should be 'char' in data type.
      >
      Just LTRIM or STRIP the leading 0s
      >
      --
      Serge Rielau
      DB2 Solutions Development
      IBM Toronto Lab- Hide quoted text -
      >
      - Show quoted text -
      Hi Serge ,

      Thanks It worked . I did modified it a bit .

      Thanks :)
      Regards
      Bikash Karan

      Comment

      Working...