Difference between Implicit and Explicit Cursors
Databases such as ORACLE have a memory area, where processing of instructions and fetched data takes place.A cursor is a pointer which is pointing to this area.The data contained in this memory area is also known as Active Set. Cursors can be broadly classified into Implicit Cursors and Explicit Cursors.
Difference between Implicit and Explicit Cursors :
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
|Implicit Cursors||Explicit Cursors|
|Implicit cursors are automatically created when select statements are executed.||Explicit cursors needs to be defined explicitly by the user by providing a name.|
|They are capable of fetching a single row at a time.||Explicit cursors can fetch multiple rows.|
|They are more vulnerable to errors such as Data errors, etc.||They are less vulnerable to errors(Data errors etc.)|
|Provides less programmatic control to the users||User/Programmer has the entire control.|
|Implicit cursors are less efficient.||Comparitive to Implicit cursors, explicit cursors are more efficient.|
Implicit Cursors are defined as:
BEGIN SELECT attr_name from table_name where CONDITION; END
Explicit cursors are defined as:
DECLARE CURSOR cur_name IS SELECT attr_name from table_name where CONDITION; BEGIN ...
|Implicit cursors requires anonymous buffer memory for storage purpose.||Explicit cursors use user-defined memory space for storage purpose|
|Cursor attributes use prefix “SQL”. |
Structure for implicit cursors: SQL%attr_name
Few implicit cursors attributes are: SQL%FOUND, SQL%NOTFOUND, SQL%ROWCOUNT
|Structure for explicit cursors: cur_name%attr_name |
Few explicit cursors are: cur_name%FOUND, cur_name%NOTFOUND, cur_name%ROWCOUNT