【发布时间】:2019-01-06 06:55:15
【问题描述】:
我正在尝试替换此调用:
cursor = connection.cursor()
try:
sql = "select m.lat, m.longt, v.tmax from vcsn_view v, vcsn_metadata m where set_vcsn('local_day=to_date(20180304)-1') is null and v.agent_no = m.agent_no(+) order by 1,2"
cursor.execute(sql)
for lat, longt, tmax in cursor:
print("Values:", lat, longt, tmax)
except cx_Oracle.DatabaseError, e:
printf ('Failed to select\n')
printException(e)
exit(1)
使用将查询中的日期作为变量的调用,即:
cursor = connection.cursor()
try:
sql = "select m.lat, m.longt, v.tmax from vcsn_view v, vcsn_metadata m where set_vcsn('local_day=to_date(:1)-1') is null and v.agent_no = m.agent_no(+) order by 1,2"
cursor.execute(sql, (20180304,))
for lat, longt, tmax in cursor:
print("Values:", lat, longt, tmax)
except cx_Oracle.DatabaseError, e:
printf ('Failed to select\n')
printException(e)
exit(1)
但我无法让它工作。我得到错误:
选择失败
错误代码 = 1036
错误消息 = ORA-01036: 非法变量名称/编号
【问题讨论】:
标签: python-2.7 data-binding cx-oracle