Explain to me the concept of a cursor in Oracle. Better with an example. How is this different from the procedure?
1 answer
CURSOR is a pointer (although as such, there is no “pointer” concept in PL / SQL!) To the context memory area, with which the PL / SQL program can control the context area and its state during operator processing.
The cursor declaration determines which expression in the SQL language will be passed to the SQL Statement Executor (the system that executes the SQL expression). The cursor can be any valid SQL statement! Also, the cursor is the main basic building block for building PL / SQL blocks. Cursors provide a cyclic mechanism for operating data sets in a database. The cursor can return one or more rows of data or none at all.
Two types of cursors are supported in PL / SQL: explicit and implicit. An explicit cursor is declared by the developer, and an implicit cursor does not require a declaration.
The cursor can return a single row, multiple rows, or a single row. For queries that return more than one row, you can only use an explicit cursor. To re-create the result set for other parameter values, the cursor must be closed and then re-opened.
The cursor can be declared in the declaration sections of any PL / SQL block, subroutine (procedure or function), or package.
- here it is only partially taken from the first steps ... I added more from myself ... - IntegralAL