1 create or replace procedure p_test
2 as
3 v_G VARCHAR2(10);
4 begin
5 begin
6 select name into v_G from test where id =1;
7 exception
8 when no_data_found then
9 v_G:='hhh';
10 end;
11 dbms_output.put_line(v_G);
12* END;
SQL> /
select into 变量 时如果没有符合条件的记录会出错的,可以把语句嵌进块中,用异常捕获
如:
begin
Select gxbj Into v_GXBJ From DJ_JTSJ Where jh=p_JingHao;
EXCEPTION/*处理异常*/
WHEN OTHERS THEN
null;
end;