简体   繁体   中英

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:

  1. ORA-01036 raises due to list elements are not wrapped up with square brackets

  2. ORA-00947 will raise after fixing the first matter, since the Col_name is not wrapped up with parentheses within the Insert statement

    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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM