1 隐式游标用法
declare
cursor cur_role is select role_id,role_name from tpl_role_t ;
role cur_role%rowtype;
begin
for role in cur_role loop
if role.role_name not in('','') then
dbms_output.put_line(role.role_id||role.role_name);
end if;
end loop;
end;
2 显示游标用法
declare
cursor cur_role is select role_id,role_name from tpl_role_t ;
role cur_role%rowtype;
begin
open cur_role
loop
fetch cur_role into role;
exit when cur_role%notfound
if role.role_name not in('','') then
dbms_output.put_line(role.role_id||...);
end if;
end loop;
close cur_role;
end loop;
end;
注:exit when %notfound 是配合 fetch 使用的