xy185(兔子) 不是变量的问题吧 select aaa into var1 from tablea 本身就会出错
declare var1 tablea.aaa%type; begin select aaa into var1 from tablea; exception when others then ... end; /
如果记录为空 select nvl(aaa,0) into var1 from tablea 如果没有记录 begin select nvl(aaa,0) into var1 from tablea exception when no_data_found then ... when others then ... end;
select count(*) into v_cou from table; if v_cou>0 then select field into v_field form table end if;
if exist(select.....) then ......... else ............
不是变量的问题吧
select aaa into var1 from tablea 本身就会出错
var1 tablea.aaa%type;
begin
select aaa into var1 from tablea;
exception
when others then
...
end;
/
select nvl(aaa,0) into var1 from tablea
如果没有记录
begin
select nvl(aaa,0) into var1 from tablea
exception
when no_data_found then
...
when others then
...
end;
if v_cou>0 then
select field into v_field form table
end if;
.........
else
............
应该用select max(colname)或者select min(colname) 来解决。
exception when no_data_found then
var1 := 0;
如果还和其他语句放在一起。
最好将该SQL语句独立作成块。
我也是:)