create or replace procedure add_user is cursor cur is select * from a_user where rownum < 10; l_user a_user%rowtype; begin -- open cur; //报错, 游标已打开 for l_user in cur -- 游标自动打开 loop dbms_output.put_line(l_user.username); end loop; -- 游标自动关闭 --close cur; //报错,无效的游标 end; create or replace procedure add_user is cursor cur is select * from a_user where rownum < 10; l_user a_user%rowtype; begin open cur; loop exit when cur%notfound ; fetch cur into l_user; dbms_output.put_line(l_user.username); end loop; close cur; end;