#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Pakistan
    Posts
    31
    Rep Power
    13

    Question Storing large numbers in oracle


    my friend is facing a problem and as i haven't done much work in oracle so thought to post question here.... these are her words:

    i have to store a phone number in database and i declared it as "phone number(20,0)", but the problem is that whenever a number having width of more than 15 digits is stored oracle converts the number in exponent and stores so when i retrieve i get first 15 digits correct and after that all 0s. one option is to store phone number as a string but i dun want to do it until n unless its the only way out......so is there ne way of storing the number of size 20 without it being converted to exponent???
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Maybe you should try storing it in a CHAR or VARCHAR field instead?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2002
    Posts
    693
    Rep Power
    26

    Re: Storing large numbers in oracle


    Originally posted by dreamz
    my friend is facing a problem and as i haven't done much work in oracle so thought to post question here.... these are her words:

    i have to store a phone number in database and i declared it as "phone number(20,0)", but the problem is that whenever a number having width of more than 15 digits is stored oracle converts the number in exponent and stores so when i retrieve i get first 15 digits correct and after that all 0s. one option is to store phone number as a string but i dun want to do it until n unless its the only way out......so is there ne way of storing the number of size 20 without it being converted to exponent???
    I have done a lot of work with Oracle and I find this VERY hard to believe, it's probably the way it is being formatted when she displays it.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2002
    Posts
    55
    Rep Power
    13
    Uh, I just had a 2 minute play, with this code:

    PHP Code:
    SQLcreate table tryx1(
      
    2           val NUMBER(30)
      
    3  );

    Table created.

    SQL
    SQLinsert into tryx1 (valvalues (12345678901234567890);

    1 row created.

    SQLselect valto_char(val'99999999999999999999'from tryx1;

           
    VAL TO_CHAR(VAL,'99999999
    ---------- ---------------------
    1.2346E+19  12345678901234567890

    SQL> 
    SQL> drop table tryx1;

    Table dropped. 
    So it looks like there's no problem with Oracle's handling of large numbers.

    Perhaps it's the mechanism you're using to read out the data?

IMN logo majestic logo threadwatch logo seochat tools logo