-
Hi,
I like to know whether it is possible to intersect two cursors returned by two separate queries(each cursor returns the same number of columns with same datatype) instead of INTERSECTing the queries.
This is of high necessity.
Any relevant help would highly be appreciated...
Thanks..
Sultan.
-
Use a ref cursor, here is an example:
The power of cursor variables comes from their ability to point to different cursors. In the following package example, a discriminant
is used to open a cursor variable to point to one of two different cursors:
CREATE OR REPLACE PACKAGE Emp_dept_data AS
TYPE Cv_type IS REF CURSOR;
PROCEDURE Open_cv (Cv IN OUT cv_type,
Discrim IN POSITIVE);
END Emp_dept_data;
CREATE OR REPLACE PACKAGE BODY Emp_dept_data AS
PROCEDURE Open_cv (Cv IN OUT cv_type,
Discrim IN POSITIVE) IS
BEGIN
IF Discrim = 1 THEN
OPEN Cv FOR SELECT * FROM Emp_tab WHERE Sal > 2000;
ELSIF Discrim = 2 THEN
OPEN Cv FOR SELECT * FROM Dept_tab;
END IF;
END Open_cv;
END Emp_dept_data;
-
Hi,
We are not asking about Returning any one of two cursors from the stored procedure. We are asking about the intersecting the Cursors after the execution of Query. DBAs can answer this question........
Regards,
Sultan.