Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2003
    Posts
    26

    Unanswered: Float gets truncated

    Hi,

    I have a table with a float(126) field.

    When I insert data (e.g. 123456.302509) it inserts fine but when I select it, I find that it has truncated the data (e.g. 123456.3)

    I need it to display at least three decimal places (to the right).

    Other data, loaded with the initial installation, seems to display properly.

    Any idea what may cause this?

    John

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    PEBKAC!
    Problem Exists Between Keyboard And Chair.
    It works OK for me.
    SQL> create table bcm_test
    2 ( id float(63)
    3 )
    4 /

    Table created.

    SQL> insert into bcm_test values(123456.302509)
    2 /

    1 row created.

    SQL> commit
    2 /

    Commit complete.

    SQL> column id format 999,999,999,999.99999999
    SQL> select * from bcm_test
    2 /

    ID
    -------------------------
    123,456.30250900

  3. #3
    Join Date
    Dec 2003
    Posts
    74
    you need to set you column to be in a specific numeric format

    on my acconts table I will change the format of my balance field.

    column balance format 999,999,999.9999999999999999999999;

    BALANCE
    -----------------------------------
    9,382,398.0000000000000000000000
    92,100.0000000000000000000000
    9,880.0000000000000000000000
    -4,000.0000000000000000000000
    10,100.0000000000000000000000
    -100.0000000000000000000000
    -34.0000000000000000000000
    30,000.0000000000000000000000

  4. #4
    Join Date
    Oct 2003
    Posts
    26
    Originally posted by anacedent
    PEBKAC!
    Problem Exists Between Keyboard And Chair.
    It works OK for me.
    SQL> create table bcm_test
    2 ( id float(63)
    3 )
    4 /

    Table created.

    SQL> insert into bcm_test values(123456.302509)
    2 /

    1 row created.

    SQL> commit
    2 /

    Commit complete.

    SQL> column id format 999,999,999,999.99999999
    SQL> select * from bcm_test
    2 /

    ID
    -------------------------
    123,456.30250900
    Anacedent,

    You crack me up! I love reading your responses - and these acronyms you come with, they are hilarious! How do you pronounce PEBKAC anyway?

    I tried the format command and it works the way you said it would BUT I have another question then...

    How come one column will display three digits and the other only displays two? Why do I have to format each column? I mean if a 'global' formatting command was set incorrectly then I would think that all float columns would display the same.

    BTW - I noticed that you didn't do a select before you formatted the column. Any idea what it would have displayed??

    And thanks for your quick response!

    John

  5. #5
    Join Date
    Sep 2003
    Location
    Milan, Italy
    Posts
    130

    Re: Float gets truncated

    Originally posted by ruluckie
    When I insert data (e.g. 123456.302509) it inserts fine but when I select it, I find that it has truncated the data (e.g. 123456.3)
    It worked perfectly for me - how are you inserting the table, using sqlplus, Java or other ? Try posting the statement, and the table definition.

    Any trigger defined on the table ?

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >How do you pronounce PEBKAC anyway?
    PEB-KAC; with soft sounding for both vowels.
    >Any idea what it would have displayed??
    Other than pure laziness, what is stopping you from doing your OWN experimentation while expecting others to spoon feed you information?

  7. #7
    Join Date
    Oct 2003
    Posts
    26
    Originally posted by anacedent
    >How do you pronounce PEBKAC anyway?
    PEB-KAC; with soft sounding for both vowels.
    >Any idea what it would have displayed??
    Other than pure laziness, what is stopping you from doing your OWN experimentation while expecting others to spoon feed you information?
    Ouch! That was a zinger!

    I did my experimentation before I started this thread... Turns out that without formatting the column, I have some columns that 'automatically' display three digits and some that only display one or two.

    I also noticed that you didn't do a select before formatting and I thought I would gain some insight as to WHY - if my original question was I have a table with 5 float fields... would you have formatted each field before doing that final select?

    But you're right, I'll do some research at http://tahiti.oracle.com to find out why all float values need to be formatted individually...

    BTW - Thanks All!

    John
    Last edited by ruluckie; 01-05-04 at 11:36.

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    What happens just MIGHT depend on the Operating System (OS), OS version, version of Oracle, AND local customizations (glogin.sql, etc).
    It all depends.
    Your reality is what happens in YOUR enviroment.
    What happens for me, may or may not happen for you.

Posting Permissions

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