I'm using pyODBS to connect to Oracle database. Connection and executing SELECT query works fine. The only problem is error on UPDATE query executing. I have table:
CREATE TABLE stud
(num NUMBER(6) NOT NULL,
fname NVARCHAR2(70),
year NUMBER(4),
bday DATE,
plata NUMBER(1) DEFAULT 0 CHECK(plata IN (0,1)),
mb NUMBER(3,2),
money NUMBER(7,2),
adr NVARCHAR2(70),
CONSTRAINT stud_num_pk PRIMARY KEY(num),
CONSTRAINT stud_num_ck CHECK (num>1000));
And I'm trying to change a record:
cursor = con.cursor()
query = '''
UPDATE stud
SET fname = ?
WHERE num = ?
'''
print rec['fname'], Decimal(rec['num'])
cursor.execute(query, (rec['fname'], Decimal(rec['num'])))
con.close()
And get output:
Иванов Игорь Петрович 535635
Traceback (most recent call last):
File "./browser.py", line 100, in on_b_save_clicked
msg = self.provider.save(rec)
File "./browser.py", line 66, in save
self.rows = cursor.execute(query, (rec['fname'], Decimal(rec['num'])))
pyodbc.Error: ('HY000', '[HY000] [Easysoft][ODBC-ORACLE WP Driver][ORACLE]ORA-01461: can bind a LONG value only for insert into a LONG column at offset 4 (1461) (SQLExecDirectW)')
But according to this page, I should use Decimal type to set NUMBER value.
What is wrong and where can I convert type?
NOTE: If I put actual vaues instead of '?'s, query is successful.