0
悬赏园豆:100 [待解决问题] 浏览: 12次我向 变量 num1 赋值
select AFG_ISUSED into num1 from app_config ac where ac.afg_key = '01';
但是 app_config 表里面没有数据 所以就报 找不到数据的错误。 怎么解决呢跪求啊
悬赏园豆:100 [待解决问题] 浏览: 12次我向 变量 num1 赋值
select AFG_ISUSED into num1 from app_config ac where ac.afg_key = '01';
但是 app_config 表里面没有数据 所以就报 找不到数据的错误。 怎么解决呢跪求啊
num1:='';
v_count number;
num1 number;
begin
select count(*) into v_count from app_config ac where ac.afg_key = '01';
if v_count >0 then
select AFG_ISUSED into num1 from app_config ac where ac.afg_key = '01';
else
num1 := null;
end if;
end;
要么写成
declare
num1 number;
begin
select AFG_ISUSED into num1 from app_config ac where ac.afg_key = '01';
exception
when no_data_found then
num1:=null;
end;
要么写成
declare
num1 number;
begin
select AFG_ISUSED into num1 from app_config ac where ac.afg_key = '01';
exception
when no_data_found then
num1:=null;
end;
begin
--select语句
exception when no_data_found then
--没值你要干的事情
end;
也不会影响到你后面的语句的执行