Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    35

    Unanswered: varchar to decimal conversion

    deci is in char(10).I have even tried varchar(10)
    set deci = '100.12';
    SELECT DECIMAL (deci,13,2,'.')
    INTO amount_involved_D
    FROM SYSIBM.SYSDUMMY1 ;
    WHEN I RUNTHIS STATMENT IN QMF, THERE IS NO PROBLEM. BUT WHEN I RUN IT IN DB2 STORED PROC BUILDER V 7.2 PROPER CONVERSION DOES NOT TAKE PLACE. The Digits after decimal are replaced by zero. Is there some other way of casting varchar or char to decimal. I have even tried using float instead of decimal.

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605

    Re: varchar to decimal conversion

    I don't know how it works in db2 stored proc builder, but you can try following conversion:
    SELECT CAST(DECI AS DEC(13,2)) FROM Table_name

    Originally posted by manish21
    deci is in char(10).I have even tried varchar(10)
    set deci = '100.12';
    SELECT DECIMAL (deci,13,2,'.')
    INTO amount_involved_D
    FROM SYSIBM.SYSDUMMY1 ;
    WHEN I RUNTHIS STATMENT IN QMF, THERE IS NO PROBLEM. BUT WHEN I RUN IT IN DB2 STORED PROC BUILDER V 7.2 PROPER CONVERSION DOES NOT TAKE PLACE. The Digits after decimal are replaced by zero. Is there some other way of casting varchar or char to decimal. I have even tried using float instead of decimal.

  3. #3
    Join Date
    Jan 2003
    Posts
    35

    Re: varchar to decimal conversion

    [QUOTE]Originally posted by grofaty
    I don't know how it works in db2 stored proc builder, but you can try following conversion:
    SELECT CAST(DECI AS DEC(13,2)) FROM Table_name
    [/QUOTE
    Thanks for your reply. It worked out.

Posting Permissions

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