PL/SQL - Explicit cursor

> Procedural Languages > PL/SQL - (Procedure Language|PL) SQL

1 - About

Unlike an cursor variable, which refers to different work areas, a explicit cursor refer always to the same query.

Advertising

3 - Initialization

3.1 - Simple

DECLARE
   CURSOR Vc_emp IS SELECT * FROM EMP;
BEGIN
  ...
END;

3.2 - Parameterized

CURSOR low_paid (num PLS_INTEGER) IS
  SELECT empno 
    FROM emp
   WHERE ROWNUM <= num
ORDER BY sal ASC;

4 - Management

4.1 - Loop

OPEN myCursor;
LOOP
  FETCH myCursor INTO myRecord;
  EXIT WHEN myCursor%NOTFOUND;
END LOOP;
CLOSE myCursor;

where:

lang/plsql/cursor_explicit.txt · Last modified: 2017/09/06 22:18 by gerardnico