判斷是否為空不可用“=” 應該使用
is null    is not null

解决方案 »

  1.   

    v_id:=' ';不是空串,而是一个空格字符串
      

  2.   

    select id into v_id from test;
    如果记录有多条或者没有记录都会报异常
    改成:
       select count(id) into v_id from test where ....;
       这样不管有没有合条件的记录,都不会抛异常
    接下来可以这样判断
      if v_id = 0 then --没有记录
        ... 
      else 
        ...
      end if
      

  3.   

    先用select count(*) into num from test;
    然后判断num是否为零。
    这样能满足要求,不知是否是你想要的?
      

  4.   

    DECLARE
      v_id varchar(10);
    begin
      select id into v_id from test;
      commit;
    exception
      when no_data_found then
        Dbms_Output.put_line('no result');
      when too_many_rows then
        Dbms_Output.put_line('multi result');
    end;