ORACLE:未找到数据——但数据存在
调试包过程,当实际上有数据时却找不到数据。
仅测试 SELECT
SELECT trim(trailing '/' from GL_SECURITY) as DUMMY
FROM b2k_user@b2k
WHERE sms_username = 'FUCHSB';
这很高兴地返回我的值:'23706*706'
一旦我尝试将此选择为 INTO,我就会收到 NO_DATA _FOUND 错误 (注释掉我放入的错误处理)
set serveroutput on
DECLARE
p_BAS_user_name varchar2(20);
v_gl_inclusion varchar2(1000);
v_gl_exclusions varchar2(1000);
BEGIN
--inputs
p_BAS_user_name := 'FUCHSB';
dbms_output.put_line(p_BAS_user_name);
----- GOOD -----
--BEGIN
SELECT trim(trailing '/' from GL_SECURITY) as DUMMY
INTO v_gl_inclusion
FROM b2k_user@b2k
WHERE sms_username = p_BAS_user_name;
--EXCEPTION
-- WHEN NO_DATA_FOUND THEN
-- v_gl_inclusion := 'SUPER EFFING STUPID';
--END;
dbms_output.put_line(v_gl_inclusion);
END;
Error report:
ORA-01403: no data found
ORA-06512: at line 12
01403. 00000 - "no data found"
*Cause:
*Action:
FUCHSB
我可以很好地捕获错误,除了基于第一个查询我 100% 知道数据库中存在 FUCHSB 的值。
任何想法..我真的开始鄙视Oracle。是的,此查询正在数据链路上运行,如第一个查询中所示,数据就在那里。
谢谢
解决 SQL Developer 中的奇怪行为使我忽略了潜在的空白:
看起来好像 SQL Developer 在运行独立选择时在执行“WHERE sms_username = p_BAS_user_name;”时应用了自己的修剪比较器部分..事实证明,当坐在包中时,它并没有..一堆空白导致了问题..仍然奇怪的是它在正常选择中返回。不过谢谢!
Debugging a package procedure and am getting a no data found when there is in fact data.
Testing just the SELECT
SELECT trim(trailing '/' from GL_SECURITY) as DUMMY
FROM b2k_user@b2k
WHERE sms_username = 'FUCHSB';
This happily returns my value : '23706*706'
As soon as i try to have this selected INTO i get a NO_DATA _FOUND error
(commented out the error handling i put in)
set serveroutput on
DECLARE
p_BAS_user_name varchar2(20);
v_gl_inclusion varchar2(1000);
v_gl_exclusions varchar2(1000);
BEGIN
--inputs
p_BAS_user_name := 'FUCHSB';
dbms_output.put_line(p_BAS_user_name);
----- GOOD -----
--BEGIN
SELECT trim(trailing '/' from GL_SECURITY) as DUMMY
INTO v_gl_inclusion
FROM b2k_user@b2k
WHERE sms_username = p_BAS_user_name;
--EXCEPTION
-- WHEN NO_DATA_FOUND THEN
-- v_gl_inclusion := 'SUPER EFFING STUPID';
--END;
dbms_output.put_line(v_gl_inclusion);
END;
Error report:
ORA-01403: no data found
ORA-06512: at line 12
01403. 00000 - "no data found"
*Cause:
*Action:
FUCHSB
I can catch the error just fine except for the fact that based on the 1st query i know 100% there is a value for FUCHSB in the database.
Any ideas.. I'm really starting to despise Oracle. Yes this query is being run over a datalink as seen in the 1st query the data is there.
Thanks
SOLVED strange behavior in SQL developer caused me to overlook potential whitespace:
It looks as though SQL Developer when running the standalone select applies its own trimming comparator when doing the 'WHERE sms_username = p_BAS_user_name;' portion.. turns out when sitting in the package it does not.. bunch of white space was causing the issue.. still strange that it returns on the normal select. Thanks though!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很确定我找到了此行为的原因:我猜测该列实际上是 CHAR 类型而不是 VARCHAR2。
请考虑以下事项:
结论:
I'm pretty sure I found the cause of this behaviour: I'm guessing that the column is actually of type CHAR and not VARCHAR2.
Consider the following:
Conclusion:
我注意到同一错误的另一个问题。
第 xx 行错误:
ORA-01403: 未找到数据
ORA-06512: 在第 xx 行
如果查询没有返回数据,则会抛出上述错误。
I noticed another issue for the same error.
ERROR at line xx:
ORA-01403: no data found
ORA-06512: at line xx
If the query return no data, above error will throw.