• 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 database query

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:

view source
print?
1CREATE OR REPLACE FUNCTION GetSalary
2IS
3cur_sal NUMBER;
4CURSOR cur_salary
5IS
6  SELECT salary
7  FROM employee;
8BEGIN
9OPEN cur_salary;
10FETCH cur_salary IN cur_sal;
11IF cur_salary%NOTFOUND THEN
12      cur_sal := 100000;
13END IF;
14CLOSE cur_salary;
15END;

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