Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2002
    Location
    Dallas, TX
    Posts
    2

    Red face Unanswered: DB2 double data type question

    I observed some tricky problem with DB2 double data type.

    eg.

    I created a table haijing_double with only one column called collab_id which is double type, then I did:

    insert into haijing_double values(22222222222222201)
    insert into haijing_double values(22222222222222202)
    insert into haijing_double values(22222222222222203)
    insert into haijing_double values(22222222222222204)
    insert into haijing_double values(22222222222222205)
    insert into haijing_double values(22222222222222206)
    insert into haijing_double values(22222222222222207)
    insert into haijing_double values(22222222222222208)
    insert into haijing_double values(22222222222222209)

    then I do:
    select * from haijing_double where collab_id=22222222222222205

    I got:

    COLLAB_ID
    ------------------------
    +2.22222222222222E+016
    +2.22222222222222E+016
    +2.22222222222222E+016

    3 record(s) selected.

    I was reading some articles on the web, somebody say that double will only guarantee 15 digit precision, is that true? Is there any way I can get around it? to retrieve only the record I am interested? I believe within the database, the value is kept as I inserted.

    I ran all the SQL command from DB2 command center. Is there any other client I can use to get around this problem?

    thanks a lot
    Haijing

  2. #2
    Join Date
    Dec 2002
    Posts
    134

    Re: DB2 double data type question

    The only solution is to changge data type to decimal

    You can get internal data representation for some types (including numeric) using hex function, so in your case

    select distinct hex(collab_id) from haijing_double
    DE386B93BFBC5343
    DF386B93BFBC5343
    E0386B93BFBC5343

  3. #3
    Join Date
    Dec 2002
    Location
    Dallas, TX
    Posts
    2

    Re: DB2 double data type question

    thanks for your informatin. I guess decimal is the solution, there is no clean way to get around it using DOUBLE.

    Haijing

Posting Permissions

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