Closed jadon1979 closed 11 years ago
That's because Oracle number is not an integer. http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832
If the "display_order" column contains integer values only, you need to declare the column type
as INTEGER
or NUMBER(38)
.
(INTEGER
is an alias of NUMBER(38)
)
I was afraid you would say that.
What is your request?
If the column type is NUMBER(38)
, ruby-oci8 get the values as Integer
because ruby-oci8 knows that the data type has no decimal parts.
If you want to explicitly get the column values as integer, use OCI8::Cursor#define
.
If you want to get all NUMBER columns as Integer
, set OCI8::BindType::Mapping[:number] = OCI8::BindType::Integer
in advance.
All decimal parts are ignored instead.
If you want to get the NUMBER value as Integer
(when it doesn't have decimal parts) or Float
(others), set OCI8::BindType::Mapping[:number] = OCI8::BindType::BasicNumberType
in advance.
If a column value has decimal parts and its precision is over 15, it is rounded to fit to the precision of Float.
I managed it with define. Thanks.
Can we fix this in the display?
@tallenaz
Sorry for the noise @kubo, I'll open a new issue if necessary.
I have a table with a column named "display_order". This Number type is being converted within oci8 upon fetch and/or fetch_hash.
display_order 123 becomes "123.0"