Oracle - 未找到数据错误和使用 NVL 的查询
SELECT NVL(FIELD1,0),NVL(FIELD2,0)
INTO var1, var2
FROM TABLEONE
WHERE SomeField_ID = 11111
AND SomeOtherFieldID in (1,2)
AND SomeStatusID in (250,360)
这是在触发器内部,我收到“未找到数据”错误。 nvl
不应该在两个变量上替换 0 吗?如果找不到记录,如何替换0?
我很感激你的帮助。
SELECT NVL(FIELD1,0),NVL(FIELD2,0)
INTO var1, var2
FROM TABLEONE
WHERE SomeField_ID = 11111
AND SomeOtherFieldID in (1,2)
AND SomeStatusID in (250,360)
This is inside a trigger and I am getting no data found error. Shouldn't the nvl
substitute 0 on both variables? How can I substitute 0 if the records are not found?
I appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您收到
找不到数据
是因为您的查询未返回任何行,而不是由于nvl
调用...nvl
的行为如下您正确地期望:您的
where
子句可能正在过滤所有行。You are getting a
no data found
because your query is not returning any rows, not because of thenvl
invocation...nvl
will behave as you are correctly expecting:Your
where
clause is probably filtering all rows.