Opening a cursor (PL/SQL)

The result set that is associated with a cursor cannot be referenced until the cursor has been opened.

Syntax

Read syntax diagramSkip visual syntax diagramOPEN cursor-name(expression,expression)

Description

cursor-name
Specifies an identifier for a cursor that was previously declared within a PL/SQL context. The specified cursor cannot already be open.
expression
When cursor-name is a parameterized cursor, specifies one or more optional actual parameters. The number of actual parameters must match the number of corresponding formal parameters.

Example

The following example shows an OPEN statement for a cursor that is part of the CURSOR_EXAMPLE procedure:
CREATE OR REPLACE PROCEDURE cursor_example
IS
    CURSOR emp_cur_3 IS SELECT empno, ename
                        FROM emp
                        WHERE deptno = 10
                        ORDER BY empno;
BEGIN
    OPEN emp_cur_3;
        ...
END;