过程中的 Oracle 查询不返回结果
我在 Oracle[10g] 存储过程中有这个 Pl/sql 查询,它是从 C# 程序调用的。:
SELECT a,b
FROM t1, t2
WHERE
t1.Id=t2.Id
AND NVL (TO_CHAR (t1.externalId), t2.product_name) = prm_product_name
prm_product_name 是 proc 的输入参数,声明为:
prm_产品_名称 VARCHAR2
应用程序将“1000”或“2000”等作为输入参数值传递给过程,并且能够在我的 C# 应用程序中成功获取查询结果。 但是当应用程序传递特定数字(例如 1500)时,查询不会返回任何记录。我在应用程序中也没有看到任何 Oracle 异常。 当我修改如下语句时,重新编译过程,然后查询过程返回结果。
AND NVL (TO_CHAR (t1.externalId), t2.product_name) = '1500'
另外,当我使用 sql 编辑器调用它时,我能够从过程中获取结果[无需硬编码 1500]。只有当从应用程序调用它时,它才不会返回结果。 我无法理解这种行为及其根本原因。 您能否建议如何让它发挥作用?
谢谢。
I've this Pl/sql query in Oracle[10g] stored procedure which is called from C# program.:
SELECT a,b
FROM t1, t2
WHERE
t1.Id=t2.Id
AND NVL (TO_CHAR (t1.externalId), t2.product_name) = prm_product_name
prm_product_name is an input param to the proc and is declared as:
prm_product_name VARCHAR2
App passes '1000' or '2000',etc as input param value to the proc and am able to get the query results succesfully in my C# app.
But when the app passes a particular number say 1500, the query does not return any records.I dont see any oracle exception in the application either.
When I modify the statement like below,recompile the proc, then the query proc returns results.
AND NVL (TO_CHAR (t1.externalId), t2.product_name) = '1500'
Also, am able to get the results from the proc when I invoke it using sql editor[without hardcoding 1500].Only when its called from the app, it does not return results.
Am not able to understand this behaviour and its root cause.
Could you please advise on how to get this working?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们希望您的程序在这种情况下抛出 NO_DATA_FOUND 。
为什么不呢?如果没有看到整个存储过程的代码,很难说,但钱将花在实施不善的异常部分上。像这样的东西,它记录错误但不传播异常:
恐惧,就好像错误从未发生过一样。
甚至是吞噬事件的
We would expect your procedure to hurl NO_DATA_FOUND in such circumstances.
Why doesn't it? It's hard to say without seeing code for the whole stored procedure but money would be on a poorly-implemented exception section. Something like this, which records the error but doesn't propagate the exception:
Or even the dread
which swallows the event as though the error never happened.