This topic describes the usage limits on cursor variables.

  • Comparison operators cannot be used to test cursor variables for equality, inequality, null, or not null.
  • A null value 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 that is used as a stored procedure or a function parameter. The permitted parameter modes depend on the operations on the cursor variable in the stored procedure or the function.

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

For example, a stored procedure performs the OPEN FOR, FETCH, and CLOSE operations on a cursor variable that is declared as the formal parameter of the stored procedure. In this case, the parameter must be declared in IN OUT mode.