# Oracle returns floats, why?

**URL:** <https://www.ruby-forum.com/t/oracle-returns-floats-why/69440>\
**Category:** Rails\
**Created:** [September 21, 2006, 2:30am UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440 "2006-09-21T02:30:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [September 21, 2006, 2:30am UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/1 "2006-09-21T02:30:19Z")

</div>

I’m not entirely clear what is going on, but I am using the oci driver  
via Oracle Instant Client, and when I query out any fields from my  
database any NUMBER fields come back with a .0 appended to them. Did I  
do something wrong, or is there a way to turn this off?

Thanks,

Brian

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [September 21, 2006, 6:32am UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/2 "2006-09-21T06:32:38Z")

</div>

Brian J. wrote:

> I’m not entirely clear what is going on, but I am using the oci driver  
> via Oracle Instant Client, and when I query out any fields from my  
> database any NUMBER fields come back with a .0 appended to them. Did I  
> do something wrong, or is there a way to turn this off?

Fixed in trunk.

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [September 21, 2006, 4:08pm UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/3 "2006-09-21T16:08:01Z")

</div>

> Brian J. wrote:
> 
> > I’m not entirely clear what is going on, but I am using the  
> > oci driver  
> > via Oracle Instant Client, and when I query out any fields from my  
> > database any NUMBER fields come back with a .0 appended to  
> > them. Did  
> > I do something wrong, or is there a way to turn this off?
> 
> Fixed in trunk.

How was it fixed, exactly? The Oracle NUMBER type can be integer or  
floating point (it’s actually stored internally in decimal format). Are  
you checking the scale, and returning an integer only if the scale is  
zero?

- Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [October 5, 2006, 12:11am UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/4 "2006-10-05T00:11:25Z")

</div>

When you say ‘trunk’, is that the OCI8 driver? Ruby? Or Rails?

I checked EdgeRails into my project, but the same problem occurs.  
Guessing that wasn’t it?

Brian

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [September 22, 2006, 11:28pm UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/5 "2006-09-22T23:28:32Z")

</div>

Berger, Daniel wrote:

> How was it fixed, exactly? The Oracle NUMBER type can be integer or  
> floating point (it’s actually stored internally in decimal format). Are  
> you checking the scale, and returning an integer only if the scale is  
> zero?

Yep. So if the column is explicitly defined in the db as being an  
integer, you get an integer.

---

<div class="post-metadata">

**Author:** ![brianj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@brianj](https://www.ruby-forum.com/u/brianj)\
**Post date:** [October 5, 2006, 1:17am UTC](https://www.ruby-forum.com/t/oracle-returns-floats-why/69440/6 "2006-10-05T01:17:28Z")

</div>

Brian J. wrote:

> When you say ‘trunk’, is that the OCI8 driver? Ruby? Or Rails?
> 
> I checked EdgeRails into my project, but the same problem occurs.  
> Guessing that wasn’t it?
> 
> Brian

Well, I dug through the source files and saw the changes in  
active\_record/connection\_adapters/oracle\_adapter.rb, however they don’t  
seem to be fixing the issue. I checked my database NUMBER columns, and  
they are set correctly as well.

Do I still have something misconfigured?

Brian
