不带参数游标: set serveroutput on; declare cursor mycursor is select sno,sname from student; v_sno student.sno%type; v_sname student.sname%type; begin open mycursor; fetch mycursor into v_sno,v_sname; loop if mycursor%found then dbms_output.put_line(mycursor%rowcount||' '||v_sno||' '||v_sname); fetch mycursor into v_sno,v_sname; exit when mycursor%notfound; end if; end loop; end; /------反斜杠执行 --------------------------------------------------------------------- 带参数的游标: set serveroutput on; declare cursor mycursor2(v_name student.sname%type) is select sno,sname from student where sname=v_name; v_sno student.sno%type; v_sname student.sname%type; begin open mycursor2('jack'); fetch mycursor2 into v_sno,v_sname; loop if mycursor2%found then dbms_output.put_line(mycursor2%rowcount||' '||v_sno||' '||v_sname); fetch mycursor2 into v_sno,v_sname; exit when mycursor2%notfound; end if; end loop; end; /------反斜杠执行