逻辑问题,先判断有没有取出数据,再进行相关操作 create or replace procedure aaaa is type sp_test1_cursor is ref cursor; test1_cursor sp_test1_cursor; v_name t_gxp_apply_main%rowtype; begin open test1_cursor for select * from t_gxp_apply_main where cbillcode in ('OPACG20144000100');--只能查询出一条数据 loop fetch test1_cursor into v_name; exit when test1_cursor%notfound; if v_name.cbillcode is not null or v_name.cbillcode='' then dbms_output.put_line(v_name.cpurchaseuse); end if; end loop; close test1_cursor; end aaaa;
create or replace procedure aaaa is
type sp_test1_cursor is ref cursor;
test1_cursor sp_test1_cursor;
v_name t_gxp_apply_main%rowtype;
begin
open test1_cursor for
select * from t_gxp_apply_main where cbillcode in ('OPACG20144000100');--只能查询出一条数据
loop
fetch test1_cursor
into v_name;
exit when test1_cursor%notfound;
if v_name.cbillcode is not null or v_name.cbillcode='' then
dbms_output.put_line(v_name.cpurchaseuse);
end if;
end loop;
close test1_cursor;
end aaaa;
exit when test1_cursor%notfound;