Implicit cursors: You can only return one row of results at a time (no definition, default auto-build)
Span style= "Font-family:courier new, Courier; FONT-SIZE:16PX "> explicit cursor: Requires a developer to define in advance, you can loop through the SQL statements in the cursor, return multiple rows of results
Properties of an implicit cursor:
sql%rowcout statistics The number of records processed in a cursor
sql%found If a record matching the criteria can be found in the cursor, the result is true
sql%notfound if a record that matches the condition can be found in the cursor, the result is true
sql%isopen determines whether a cursor is open, and the default cursor in an implicit cursor automatically opens
1. An implicit cursor:
Sql%NotFound If a record that matches a condition can not be found in the cursor, the result is true SQL> Declare 2 3v_id t1.id%type; 4 5 begin 6 7V_ID:=Ten; 8 9 UpdateT1SetId= - whereId=v_id;Ten ifSql%NotFound Then One Insert intoT1 (ID)Values(v_id); A Commit; - End if; - End;
2. Sql%found if a record matching the criteria can be found in the cursor, the result is true
Sql> Declare 2 3v_id t1.id%type; 4 5 begin 6 7V_ID:=Ten; 8 9 Delete fromT1whereId=v_id;Ten One ifSql%Found Then ADbms_output.put_line ('T1 Recorder is delete!'); - Commit; - End if; the End;
3.sql%rowcout statistics The number of records processed in the cursor
Sql> Declare 2 3v_id t1.id%type; 4 5 begin 6 7V_ID:=Ten; 8 9 Insert intoT1 (ID)Values(v_id);Ten Delete fromT1whereId=v_id; One A ifSql%Found Then -Dbms_output.put_line ('T1 Recorder is delete!'); -Dbms_output.put_line ('T1 Recorders'||Sql%RowCount||'rows was deleted!');//Count the number of deleted rows the Commit; - End if; - End;
PL/SQL Practice cursor cursor:oracle A private area of memory allocated for SQL statements when executing SQL statements