• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql

syntax and example of OPEN CURSOR in oracle sql

Open CURSOR in Oracle PLSQL

December 1, 2012 by techhoneyadmin

OPEN CURSOR in Oracle PLSQL is used to open a cursor before starting to access the records or results fetched. Oracle OPEN Cursor statement allows us to use the records fetched by the cursor in a PLSQL Function, package or procedure.

Oracle PLSQL Syntax of OPEN CURSOR is:

OPEN cursor_name;

Let’s understand, how to use OPEN Cursor with the help of the below Oracle PLSQL function code:

CREATE OR REPLACE FUNCTION GetSalary
IS
cur_sal NUMBER;
CURSOR cur_salary
IS
  SELECT salary
  FROM employee;
BEGIN
OPEN cur_salary;
FETCH cur_salary IN cur_sal;
IF cur_salary%NOTFOUND THEN
      cur_sal := 100000;
END IF;
CLOSE cur_salary;
END;

The code OPEN cur_salary is used to open a cursor in plsql.

We must also make sure that once we open a cursor we have to close the cursor using CLOSE CURSOR statement.

Filed Under: plsql Tagged With: CURSORPLSQL, how to OPEN CURSOR in oracle database query, how to OPEN CURSOR in oracle plsql, how to OPEN CURSOR in oracle sql, OPEN CURSOR in oracle plsql, OPEN CURSOR in oracle sql, OpenCursorPLSQL, syntax and example of OPEN CURSOR in oracle database query, syntax and example of OPEN CURSOR in oracle plsql, syntax and example of OPEN CURSOR in oracle sql, using OPEN CURSOR in oracle database query, using OPEN CURSOR in oracle plsql, using OPEN CURSOR in oracle sql

Copyright © 2025 · Parallax Pro on Genesis Framework · WordPress · Log in