插入数据时出错:cx_Oracle.DatabaseError:ORA-01722:无效的数字

时间:2018-06-07 09:45:50

标签: python-3.x oracle oracle11g pycharm

我需要将数据插入客户表

cur.execute(''' 
CREATE TABLE customer (customerId varchar(20),customerName 
varchar(20),telephoneNo int,
                        addressId int, customerType varchar(20),
                        discount int, memCardType varchar(20))''')
class customer:
    def __init__(self,customername,telephonenumber,addressid):
        self.customername=customername
        self.telephonenumber=telephonenumber
        self.addressid=addressid
        id=4
        t='a'

        cur.execute("INSERT INTO customer VALUES (:1,:2,:3,:4,:5,:6,:7)", 
   (id,customername,telephonenumber,addressid,t,id,t))
        cur.execute("SELECT * FROM customer")
        print(cur.fetchall())`
if(ch==1):
nm = input("name:")
tel = input("number:")
add = input("address")
customer(nm,tel,add)

错误:此处选择存储在变量ch中,如果ch为1,则用户询问数据并将数据存储在表中

Traceback (most recent call last):

customer(nm,tel,add)
line 23, in __init__
cur.execute("INSERT INTO customer VALUES (:1,:2,:3,:4,:5,:6,:7)",(id,customername,telephonenumber,addressid,t,id,t))
cx_Oracle.DatabaseError: ORA-01722: invalid number

0 个答案:

没有答案