Re: [cx-oracle-users] Types used for values returned from a query
Brought to you by:
atuining
|
From: Anthony T. <an...@co...> - 2005-02-10 14:50:25
|
Paul Moore wrote:
>>Oracle is quite happy to accept the string as input to a numeric column. I'm
>>not sure if that will work for you but it is an option.
>
>
> Quite possibly. I can just bind the variable as a String in Java, and
> then load it into a Number column, I guess. Could there be any format
> issues (exponential formats, commas in numbers, etc)? I only ask
> because the environemnt makes it annoyingly hard to report errors, so
> when things go wrong it's a real pain to debug :-(
Not certain. Since I've only dumped it for future import into an Oracle
database that hasn't been an issue for me. You'll have to try -- you can
find out what happens by simply issuing "to_char(number)" on any number
you would care to and looking at the resulting string.
>>>Alternatively, is there any likelihood of cxOracle using Python 2.4's
>>>Decimal type in the near future?
>>
>>Theoretically this wouldn't be all that difficult to accomplish but
>>since there is no C implementation this would mean a significant
>>performance penalty.
>>Having used the Decimal type myself in pure Python
>>I know that it is the most efficiently coded module, either. I suppose
>>this type could be returned __only__ if the data is not an integer and
>>that would mitigate the problem somewhat. Comments?
>
>
> That may be an option, but frankly, this is pretty specialised use
> where an exact representation is crucial. Maybe just having a way of
> saying that a specific column in a query must be returned as a string,
> and then doing string->Decimal in Python would be suitable. Something
> like
>
> c = cn.cursor()
> c.execute("select...")
> c.col_as_string(1)
> row = c.fetchone()
> decval = Decimal(row[1])
>
> All I really care about is having some way of being sure that there's
> no precision loss - using strings does it, the rest is just
> convenience (only using strings where it's really needed).
>
> Sorry - must dash, but I hope you get the idea...
I do and I've considered something similar. Perhaps a
cursor.define(position, data_type) which would allow you to override the
default retrieve definition. In your example the call would be
"c.define(1, cx_Oracle.STRING)". I suspect it would have to take place
before the execute() call, though. Comments, anyone?
> Paul
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> cx-oracle-users mailing list
> cx-...@li...
> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users
--
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
|