# [DB-SIG] DCOracle number handling still broken?

**Guenter Radestock
**
guenter@ubka.uni-karlsruhe.de

*Thu, 6 Apr 2000 17:07:08 +0200*

On Thu, Apr 06, 2000 at 10:50:05AM -0400, Christopher Petrilli wrote:
>* Guenter Radestock [guenter@ubka.uni-karlsruhe.de] wrote:
*>*
*>* > Some time last year I converted to DCOracle, version 1.2.1 and now I see
*>* > this does not work anymore (doesn't give an error, either). Aparantly,
*>* > DCOracle returns every number truncated to an integer (again: this would
*>* > work better with the old old oracledb.) I found that where svrmgrl
*>* > returns 1.30436094, DCOracle will return (1,) as a result to the same
*>* > select.
*>*
*>* Um, can you provide some insight into your schema? We sniff at the
*>* data types returned by Oracle, and try to do the right thing. The
*>* general number type format is:
*>*
*>* NUMBER(p,s)
*>*
*>* where 'p' is the precision (total number of digits) and 's' is the
*>* scale (or number of digits to the right of the decimal). If 's' is
*>* *not* zero, then we return a floating point, otherwise we try and get
*>* Python int v. long right (basically if p > 9, then long).
*>*
*>* I wonder if you just are using the Oracleism of NUMBER by itself,
*>* which is hard to know what it will return.
*
I do use the description "number" in my schema and I only store integer
values in the database itself. Cursor.description after a select
returns the tuple (('AVG(AUSGELIEFERT-ERZEUGT)', 'NUMBER', 40, 22, 0, 0,
1),) The problem must be with avg() here. I find the following:
create table numtest (x number, y number(4), z number(4, 2));
insert into numtest values (1, 2, 3.4);
insert into numtest values (5, 6, 7.8);
>>>* cu.execute('select * from numtest')
*>>>* cu.fetchone()
*(1, 2, 3.4)
cu.description
(('X', 'NUMBER', 40, 22, 0, 0, 1), ('Y', 'NUMBER', 40, 22, 4, 0, 1),
('Z', 'NUMBER', 40, 22, 4, 2, 1))
>>>* cu.execute('select avg(x), avg(y), avg(z) from numtest');
*>>>* cu.fetchone()
*(3, 4, 5)
>>>* cu.description
*(('AVG(X)', 'NUMBER', 40, 22, 0, 0, 1), ('AVG(Y)', 'NUMBER', 40, 22, 0,
0, 1), ('AVG(Z)', 'NUMBER', 40, 22, 0, 0, 1))
--
Guenter Radestock, Universitaetsbibliothek Karlsruhe
guenter@ubka.uni-karlsruhe.de
http://www.ubka.uni-karlsruhe.de/~guenter