Re: [cx-oracle-users] float vs. int
Brought to you by:
atuining
From: Marcos P. <msa...@gr...> - 2003-10-06 18:27:13
|
But other interfaces do return the right thing, =BFdon't they? I mean, odbc and SQL*Plus. (Can't check right now though) El lun, 06-10-2003 a las 19:17, Anthony Tuininga escribi=F3: > On Sat, 2003-09-27 at 21:27, Geoff Gerrietts wrote: > > Quoting Geoff Gerrietts (ge...@ge...): > > > What are the criteria for deciding when a NUMBER will be returned as > > > a float, or when it will be returned as an int or long? > >=20 > > Terribly sorry; found the answer in the mailing list archives. >=20 > No problem. This isn't the first time the problem has appeared. It is > one of those things that annoys me every time I think about it. But I > haven't found a really useful solution so far. >=20 > > I think for my uses, anything with a scale 0 < sys.maxint should be an > > integer, and anything with a scale 0 > sys.maxint should be a long. > > This does not violate the principle of least surprise, and it also > > relieves me of the burden of post-processing every query result so > > CORBA doesn't barf. >=20 > That should be quite reasonable and simple to implement. I am assuming > that you mean "value" when you state "scale" above, right? Does anyone > have any objections to that implementation? Of course, it doesn't solve > the problem that most people immediately complain about, which is "Why > do I get a float back when I issue the query 'select count(*) from > table'"? Unfortunately, Oracle returns a scale of "0" and a precision of > "0" meaning no information is available as to whether an integer or a > floating point number is being returned. >=20 > > With decimals, it would be nice to work with fixed point rather than > > floats, but that would likely be a substantial change in my > > application: floats are everywhere, and in several places, I expect > > them to be floats. >=20 > True. I've considered adding an extension which would allow > specification of what is to be returned. I still haven't come up with a > reasonable name for it or whether I should overload setoutputsize() in > some way. Essentially, it would mean the following: >=20 > cursor.somefunc(1, cx_Oracle.INTEGER) > cursor.somefunc(2, cx_Oracle.FLOAT) > cursor.somefunc(3, cx_Oracle.FIXED_POINT) >=20 > where of course, the constants defined above don't exist yet and > "somefunc" needs to be named properly so that it makes sense. Any > suggestions? >=20 > > Thanks, > > --G. --=20 Marcos S=E1nchez Provencio <msa...@gr...> www.burke.es |