The restrictions on cursor variable usage are as follows:

  • Comparison operators cannot be used to test cursor variables for equality, inequality, null, or not null.
  • Null cannot be assigned to a cursor variable.
  • The value of a cursor variable cannot be stored in a database column.
  • Static cursors and cursor variables are not interchangeable. For example, a static cursor cannot be used in an OPEN FOR statement.

In addition, the following table describes the permitted parameter modes for a cursor variable used as a procedure or function parameter depending upon the operations on the cursor variable within the procedure or function.

Table 1. Permitted cursor variable parameter modes
Operation IN IN OUT OUT
OPEN No Yes No
FETCH Yes Yes No
CLOSE Yes Yes No

For example, if a procedure performs the OPEN FOR, FETCH, and CLOSE operations on a cursor variable declared as the formal parameter of the procedure, that parameter must be declared with IN OUT mode.