Cursor variables
Cursor variables provide a unique service to refer to different context areas in SGA as they can be associated to more than one SELECT
statement in the same block. While static cursors remain stuck to a single static SELECT
, cursor variables purely act like a pointer variable. At runtime, the pointer can be moved to point to different work areas having different SELECT
statements and hence, different result sets.
By virtue of their behavior, a cursor variable differs from a static cursor. Static cursors have the life cycle of only one SQL processing, but cursor variables can live for many SQL statements. Once the processing under a work area is finished, they are ready to move on and point to a different work area. Cursors cannot be passed as arguments, but cursor variables can pass the result sets to other programs and even client environments. These indifferent properties make cursor variables a robust and flexible code feature in PL/SQL.
Cursor variables can be very handy...