views:

53

answers:

1

I'm trying to fetch some data from a column whose DATA_TYPE=NUMBER(1,0) with this piece of code:

import cx_Oracle
conn = cx_Oracle.connect(usr, pwd, url)
cursor = conn.cursor()
cursor.execute("SELECT DELETED FROM SERVICEORDER WHERE ORDERID='TEST'")
print(cursor.fetchone()[0])

which complains thus:

Traceback (most recent call last):
  File "main.py", line 247, in <module>
    check = completed()
  File "main.py", line 57, in completed
    deleted = cursor.fetchone()[0]
cx_Oracle.DatabaseError: OCI-22061: invalid format text [T

Replacing 'DELETED' column with one whose DATA_TYPE=VARCHAR2 does not throw such a complaint.

A: 

A work-around is putting time.sleep(1) before cursor.fetchone():

...
cursor.execute("SELECT DELETED FROM SERVICEORDER WHERE ORDERID='TEST'")
time.sleep(1)
print(cursor.fetchone()[0])
Tshepang