[英]ORA-01036: illegal variable name/number (cx_Oracle)
When I am trying to insert data into DB and i can see the above error when i am using below code.当我尝试将数据插入数据库时,当我使用以下代码时,我可以看到上述错误。
Could you please suggest what else can be done.你能否建议还有什么可以做的。
Code:代码:
list_to_add=['Have you searched','similar question has already been posted']
dsn_tns = cx.makedsn(cred_test['HOST'], cred_test['PORT'], service_name=cred_test['SERVICE_NAME'])
conn = cx.connect(user=cred_test['USER'], password=cred_test['PASWRD'], dsn=dsn_tns)
cursor = conn.cursor()
cursor.prepare('INSERT INTO Table_name Col_name values (:0)')
cursor.executemany(None,list_to_add)
conn.commit()
You have minor issues:你有小问题:
ORA-01036 raises due to list elements are not wrapped up with square brackets ORA-01036由于列表元素未用方括号括起来而引发
ORA-00947 will raise after fixing the first matter, since the Col_name
is not wrapped up with parentheses within the Insert statement ORA-00947将在修复第一个问题后引发,因为在 Insert 语句中Col_name
没有用括号括起来
list_to_add=[['Have you searched'],['similar question has already been posted']] dsn_tns = cx.makedsn(cred_test['HOST'], cred_test['PORT'], service_name=cred_test['SERVICE_NAME']) conn = cx.connect(user=cred_test['USER'], password=cred_test['PASWRD'], dsn=dsn_tns) cursor = conn.cursor() cursor.prepare('INSERT INTO Table_name(Col_name) VALUES(:0)') cursor.executemany(None,list_to_add) conn.commit()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.