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_datedate,'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?
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_datedate,'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?