【发布时间】:2019-08-02 12:04:46
【问题描述】:
大家好,当我在查询中运行我的代码时,一切似乎都很好,但是当我将它放在存储过程中时,它会返回“未找到数据错误”。
我使用了异常处理错误,但它返回了相同的错误。
create or replace procedure test(i_d number)
as
l_text VARCHAR(900);
begin
select 'TEST, '||to_char(D3,'yy.mm.dd')|| CHR(10)||'STRINGTEXT'||D2
into l_text
from table
where id = i_d;
EXCEPTION
WHEN no_data_found THEN
-- do something
dbms_output.put_line('No records found for employee no ');
end;
我能做什么?
【问题讨论】:
-
您确定您传递的 i_d 存在于表中吗?
-
错误表明SELECT语句没有返回一行,所以条件
where id = i_d显然计算为false -
@helloandroiddevelopers
when I run the stored procedure (as a stored procedure and not as execute test(5);)是什么意思?execute test(5)正在将代码作为存储过程运行!您运行代码的另一种方式是什么? (请编辑您的问题以添加该信息) -
你在哪里运行这个程序?在 PL/SQL 开发人员中?蟾蜍? SQL开发者?还有什么?
-
@helloandroiddevelopers 然后不要从左边运行它。当您单击左侧的程序名称时,您在哪里看到“运行”?您在哪个选项卡中 - 对象选项卡?
标签: sql oracle stored-procedures plsql oracle11gr2