Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2017
    Posts
    5

    Question Answered: Did any one experienced CAST function behaving differently on different environments?

    The issue I encountered with CAST function is a strange one...

    I am running same SQL in production and UAT environments but the result I am getting is different.

    SQL:
    select CAST (TOTAL_AMT AS CHAR(13))
    from source.table1
    where year = 2017
    fetch first 10 rows only with ur;

    When I run above sql on production server, the result I am getting is 000000061.16

    When I run same sql on UAT server, the result I am getting is 61.16

    Both the servers (AIX) are on same version and DB2 version is same on both environments (10.5.8).

    Did any one face this kind of an issue?

  2. Best Answer
    Posted by mark.bb

    "As you see, the dec_to_char_fmt parameter setting is different for these databases.
    Db2 works as designed here."


  3. #2
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    306
    Provided Answers: 46
    What's the result of the following queries on both databases?
    Code:
    select value from sysibmadm.dbcfg where name='dec_to_char_fmt';
    select char(d), char_old(d) from table(values dec(61.16, 13, 2)) t(d);
    Regards,
    Mark.

  4. #3
    Join Date
    Apr 2017
    Posts
    5
    Hi Mark,

    I ran both the SQL you gave and below is the result:

    Production:
    SQL1 Result : V95
    SQL2 Result : 00000000061.16 00000000061.16


    UAT:
    SQL1 Result: NEW
    SQL2 Result: 61.16 00000000061.16

  5. #4
    Join Date
    Jul 2016
    Location
    Moscow
    Posts
    306
    Provided Answers: 46
    As you see, the dec_to_char_fmt parameter setting is different for these databases.
    Db2 works as designed here.
    Regards,
    Mark.

Posting Permissions

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