我很难在单存储区中找到异常no_data_found。
在<>Oracle中,我们使用no_data_found异常。对于no_data_found异常,单存储区中是否有其他解决方案?
发布于 2022-07-05 20:51:59
如果它在存储过程中,则可以使用ER_INTO_VARIABLES_NO_ROWS。例子如下:
create table test(id int primary key, descr varchar(10));
insert into test values (1,'one'),(2,'two'),(3,'three');
delimiter $
create or replace procedure test_sp(inp_id int)
returns void as
declare
v_descr varchar(10);
begin
begin
select descr into v_descr from test where id = inp_id;
echo select v_descr;
exception
when ER_INTO_VARIABLES_NO_ROWS then
echo select 'No rows found';
end;
end $
delimiter ;
call test_sp(1); -- returns 'one'
call test_sp(100); -- returns 'No rows found'https://dba.stackexchange.com/questions/313712
复制相似问题