如题,后端发来一段代码,我看也没什么问题,但是执行时候偶尔会执行失败,提示找不到订单号,用 plsql 执行就可以获取数据,20 条可能有一条会执行失败,大家有没有更好的建议或者方法 代码如下
try:
cursor = connection.cursor()
ad_startdate = datetime.now() - timedelta(days=10)
ad_enddate = datetime.now()
mycs = cursor.var(cx_Oracle.CURSOR)
result = cursor.var(cx_Oracle.NUMBER)
k = cursor.execute("""begin
:result := pk_app.uf_get_order_List(as_ic_card => :as_ic_card,
ad_startdate => :ad_startdate,
ad_enddate => :ad_enddate,
mycs => :mycs);
end;
""", as_ic_card=as_ic_card, ad_startdate=ad_startdate, ad_enddate=ad_enddate, mycs=mycs,
result=result)
print("----------")
print(k)
print("refCursor = mycs.getvalue()")
refCursor = mycs.getvalue()
data_list = []
for row in refCursor:
print(row)
data_list.append(row[:])
cursor.close()
print (data_list)
except Exception as e:
print(e)
try:
cursor.close()
except Exception as e1:
print(e1)
上面是代码样例,查询最近 10 天订单
1
qile11 2022-12-19 13:50:08 +08:00 via Android
有没有哪位遇到过,谢谢
|
2
qile11 2022-12-20 15:06:38 +08:00 via Android
主题页看不到帖子啦,是不是已经沉啦
|
3
qile11 2022-12-30 22:46:46 +08:00 via Android
直接 exec 执行,返回类型可能需要处理下
|