Re: [cx-oracle-users] float vs. int
Brought to you by:
atuining
From: Anthony T. <an...@co...> - 2003-10-06 17:17:53
|
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? > > Terribly sorry; found the answer in the mailing list archives. 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. > 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. 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. > 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. 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: cursor.somefunc(1, cx_Oracle.INTEGER) cursor.somefunc(2, cx_Oracle.FLOAT) cursor.somefunc(3, cx_Oracle.FIXED_POINT) 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? > Thanks, > --G. -- Anthony Tuininga an...@co... Computronix Distinctive Software. Real People. Suite 200, 10216 - 124 Street NW Edmonton, AB, Canada T5N 4A3 Phone: (780) 454-3700 Fax: (780) 454-3838 http://www.computronix.com |