declare
ls_dxm_n varchar2(10)
your_counts number(5);
begin
select count(dxm) into your_counts from jh_gs where gcbh='2';
if your_counts!=0 then
select dxm into ls_dxm_n from jh_gs where gcbh='2';
else
null;
end if;
end;
/
ls_dxm_n varchar2(10)
your_counts number(5);
begin
select count(dxm) into your_counts from jh_gs where gcbh='2';
if your_counts!=0 then
select dxm into ls_dxm_n from jh_gs where gcbh='2';
else
null;
end if;
end;
/
你可以使用游标,或者加上异常处理。
如果返回为空或者有多条记录, 它都会产生异常:
为空时返回: no_data_found
多记录时返回:too_many_rows
所以你必须检查。