The "SQL" Mark written in the implicit cursor. For example, SQL % ROWCOUNT indicates that the implicit cursor has several rows of records. The explicit cursor is customized by the developer, you can also use C1 % ROWCOUNT to indicate the number of rows in the cursor C1. Usually, explicit cursors are opened in OPEN mode.
Use an explicitly defined cursor to OPEN it in OPEN mode. The usage is as follows:
- Set serveroutput on
- Declare
- Cursor c1 is
- Select rownum, table_name from user_tables where rownum <10;
- V_rownum number;
- V_tablename varchar2 (256 );
- Begin
- Open c1;
- Dbms_output.put_line ('current row of cursor 1: '| c1 % rowcount );
- Loop
- Fetch c1 into v_rownum, v_tablename;
- Exit when c1 % notfound;
- Dbms_output.put_line ('cursor current row: '| c1 % rowcount | 'table_name:' | v_tablename );
- End loop;
- Dbms_output.put_line ('current row of cursor 2: '| c1 % rowcount );
- Close c1;
- End;
Run the command in SQLPUS to obtain the following result.
- Current number of cursor rows: 0-1
- Cursor current row: 1 table_name: T_SS
- Cursor current row: 2 table_name: T_TARGET
- Cursor current row: 3 table_name: T_SS_NORMAL
- Cursor current row: 4 table_name: T_MYSTAT
- Cursor current row: 5 table_name: T_WXL_GETDATA_LOG
- Cursor current row: 6 table_name: ALL_OBJ
- Cursor current row: 7 table_name: DBA_OBJ
- Cursor current row: 8 table_name: T_RPT_XXX
- Cursor current row: 9 table_name: CMS_DOC_BODY
- Cursor current row