示例1: create or replace procedure pro_test_cursor is userRow t_user%rowtype; cursor userRows is select * from t_user; begin for userRow in userRows loop dbms_output.put_line(userRow.Id||','||userRow.Name||','||userRows%rowcount); end loop; end pro_test_cursor;
示例2: create or replace procedure pro_test_cursor_oneRow(vid in number) is userRow t_user%rowtype; cursor userCur is select * from t_user where id=vid; begin open userCur; fetch userCur into userRow; if userCur%FOUND then dbms_output.put_line(userRow.id||','||userRow.Name); end if; close userCur; end pro_test_cursor_oneRow;