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 Implict Cursors and Explicit Cursors.

Difference between Implicit and Explicit Cursors :

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

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.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.