[DB-SIG] Result from DCOracle2 different from sqlplus
Matthew T. Kromer
Thu, 15 Nov 2001 08:35:32 -0500
Titu Kim wrote:
> I am confused when retrieve data from database using
>same query. For instance, my query is "SELECT emp_id
>FROM EMPLOYEE" and data type of emp_id is NUMBER. If i
>execute this query using DCOracle2 in python, i get id
>number with 1 decimal number like, [[1.0],[14.0]].
>However, if i run the same query in sqlplus, i get the
>same result without any decimal point. Why can this
>happen? Any idea?
DCOracle2 takes a look at the scale and precision of the number -- by
default, NUMBERs with no scale or precision (which sometimes Oracle
represents internally as maximum precision) can contain both floating
point values and integers. When converting a column to a python type,
DCOracle2 doesn't want to have two different result types in the same
column, so if the column COULD contain a floating point, the whole
column is represented as floating point.
To force the column type to be integer only, you can declare it as
NUMBER(9) -- anything larger than this would indicate the possibility of
a Long integer being returned.