ORA-01036: 非法变量名/编号 使用 cx_orcale 更新executemany
我需要更新 oracle sql 中的大约 50 万行,但是当我尝试只更新 2 行时,出现了以下错误。我不明白我哪里出错了。
错误:
cursor.executemany(updatequery,insert_chunk)
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
我的代码:
insert_batch_size=100000
bind_update=[['BAIPS9419N', 'AADHAARSEEDINGISSUCCESSFUL'], ['ADOPL3293P', 'AADHAARSEEDINGISSUCCESSFUL']]
try:
bind_update_chunks = [bind_update[x:x+insert_batch_size] for x in range(0, len(bind_update), insert_batch_size)]
for insert_chunk in bind_update_chunks:
_updatequery="update UCIDBA.client_code_dtls set ccd_aadhaar_seeding_status = 'N',CCD_LST_MOD_BY='SYSTEM',CCD_LST_MOD_DT=SYSDATE where CCD_PAN_NO= :1"
logging.info("UpdateDBWith_Y:->Update Query : |" +updatequery)
cursor.executemany(updatequery,insert_chunk)
connection.commit()
return True
except Exception as e :
logging.exception("UpdateDBWith_Y:->: |")
return False
I need to update around 0.5 million rows in oracle sql but I am getting below error when i tried for just 2 rows .I am not understanding as to where I am going wrong .
Error :
cursor.executemany(updatequery,insert_chunk)
cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number
MY code:
insert_batch_size=100000
bind_update=[['BAIPS9419N', 'AADHAARSEEDINGISSUCCESSFUL'], ['ADOPL3293P', 'AADHAARSEEDINGISSUCCESSFUL']]
try:
bind_update_chunks = [bind_update[x:x+insert_batch_size] for x in range(0, len(bind_update), insert_batch_size)]
for insert_chunk in bind_update_chunks:
_updatequery="update UCIDBA.client_code_dtls set ccd_aadhaar_seeding_status = 'N',CCD_LST_MOD_BY='SYSTEM',CCD_LST_MOD_DT=SYSDATE where CCD_PAN_NO= :1"
logging.info("UpdateDBWith_Y:->Update Query : |" +updatequery)
cursor.executemany(updatequery,insert_chunk)
connection.commit()
return True
except Exception as e :
logging.exception("UpdateDBWith_Y:->: |")
return False
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的示例中,您有一个绑定变量 (
:1
),但每行中有两条数据。调整 SQL 以包含第二个绑定变量 (:2
) 或调整数据以仅提供一项数据。我同意该错误消息有点无用。我们正在努力在未来的版本中解决这个问题!
In your example you have one bind variable (
:1
) but you have two pieces of data in each row. Adjust the SQL to include a second bind variable (:2
) or adjust your data to only supply one piece of data.I agree that the error message is a little unhelpful. Efforts are underway to address that for a future release!