How To Open a Cursor Variable?
Submitted by: AdministratorA cursor variable must be opened with a specific query statement before you can fetch data fields from its data rows. To open a cursor variable, you can use the OPEN ... FOR statement as shown in the following tutorial exercise:
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
TYPE emp_ref IS REF CURSOR RETURN employees%ROWTYPE;
TYPE any_ref IS REF CURSOR;
emp_cur emp_ref;
any_cur any_ref;
sys_cur SYS_REFCURSOR;
BEGIN
OPEN emp_cur FOR SELECT * FROM employees;
OPEN any_cur FOR SELECT * FROM employees;
OPEN sys_cur FOR SELECT * FROM employees;
CLOSE sys_cur;
CLOSE any_cur;
CLOSE emp_cur;
END;
/
Submitted by: Administrator
CREATE OR REPLACE PROCEDURE ggl_CENTER AS
TYPE emp_ref IS REF CURSOR RETURN employees%ROWTYPE;
TYPE any_ref IS REF CURSOR;
emp_cur emp_ref;
any_cur any_ref;
sys_cur SYS_REFCURSOR;
BEGIN
OPEN emp_cur FOR SELECT * FROM employees;
OPEN any_cur FOR SELECT * FROM employees;
OPEN sys_cur FOR SELECT * FROM employees;
CLOSE sys_cur;
CLOSE any_cur;
CLOSE emp_cur;
END;
/
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How To Write Date and Time Interval Literals in Oracle? |
☺ | What Happens If You Lost a Data File? |
☺ | How Oracle Handles Dead Locks? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
☺ | How To Add a New Column to an Existing Table in Oracle? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |