ORACLE 等数据库有一个内存区域,在那里处理指令和获取的数据。游标是指向该区域的指针。包含在该内存区域中的数据也称为Active Set 。游标可以大致分为隐式游标和显式游标。
隐式游标和显式游标的区别:
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:
|
Explicit cursors are defined as:
|
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 |