New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error retrieving results from a table performing multiplication on column #34

Closed
Moataz-E opened this Issue Jun 6, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@Moataz-E
Copy link

Moataz-E commented Jun 6, 2017

In python 3.5.5 running cx_Oracle 6.0b2 and connecting to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production.

If I run a query such as:

SELECT price*100
FROM my_table

and I try to retrieve the result using fetch, python seems to fail with the error: ValueError: invalid literal for int() with base 10: '0.0157'

Does anyone know what the issue could be? If I remove the multiplication by 100 it seems to work fine without any issues.

Moataz

@cjbj

This comment has been minimized.

Copy link
Member

cjbj commented Jun 6, 2017

@Moataz-E what OS are you using? What version of Oracle client libraries (e.g. Instant Client) are you using? Got a Python code snippet so we can all be testing the same code paths?

@cjbj cjbj added the bug label Jun 6, 2017

@Moataz-E

This comment has been minimized.

Copy link
Author

Moataz-E commented Jun 6, 2017

cjbj, managed to get it fixed by using TO_BINARY_FLOAT() on the calculated number. So:

SELECT TO_BINARY_FLOAT(price*100)
FROM my_table

Thanks

@cjbj

This comment has been minimized.

Copy link
Member

cjbj commented Jun 6, 2017

@Moataz-E if you can give the info I asked for (and also some data), then it will be easier for us to fix it.

@Moataz-E

This comment has been minimized.

Copy link
Author

Moataz-E commented Jun 8, 2017

@cjbj oracle instant client 12.2.0.1.0, and running Windows 7 x64 bit. Code is a simple connection, cursor, execute sequence on the query mentioned above.

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Jun 8, 2017

@Moataz-E what is the structure of "my_table"? And the contents of one row?

@bobbydurrett

This comment has been minimized.

Copy link

bobbydurrett commented Jun 9, 2017

I'm having the same problem. I'm on Windows 7 with the full 11.2.0.4 32 bit client. Using Python 3.61. I run this code:

cur.execute('select to_char(blocks/7) from user_tables')
row = cur.fetchone()
print(row)

cur.execute('select blocks/7 from user_tables')
row = cur.fetchone()
print(row)

I get this output:

('2.28571428571428571428571428571428571429',)
Traceback (most recent call last):
File "bug.py", line 12, in
row = cur.fetchone()
ValueError: invalid literal for int() with base 10: '2.28571428571428571428571428571428571429'

Seems to be running int('2.28571428571428571428571428571428571429',base=10)
Previous version of cx_Oracle just converts this to a float.

Bobby

@anthony-tuininga

This comment has been minimized.

Copy link
Member

anthony-tuininga commented Jun 9, 2017

Thanks, Bobby. That was helpful. I have now replicated the issue and found a solution which I shall commit shortly, along with some tests to make sure this issue doesn't crop up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment