bind invalid when execute oracle sql statement.

W

wqhflp

Hi, I want to insert data into a table
SQL> desc jijin
Name Null? Type
----------------------------------------- -------- -------------
ID NOT NULL NUMBER(6)
T_TIME NOT NULL DATE
NET_VALUE NUMBER(5,4)
TOTAL_VALUE NUMBER(5,4)
INCREASE NUMBER(5,4)

The code I used is
sql="insert into jijin values
:)id,to_date:)date,'yyyymmdd'),:net_value,:total_value)"
day=int(date)

bindVars={'id':int(id),'date':int(day),'net_value':float(net),'total_value':float(total)}
cur.execute(sql,bindVars)
conn.commit()

the net ,total are in format of a string, a type of string, so we must
convert it into a number. But the problem is if we use float to convert
a string like '0.1' will be translated into 0.10000000000000001, which
is invalid for oracle type NUMBER(5,4).

How to resolve the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top