Cursor Union Or Intersection
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Cursor Union Or Intersection

  1. #1
    Join Date
    May 2002
    Posts
    6

    Question

    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.
    Regards,
    Sultan.

  2. #2
    Join Date
    Feb 2001
    Posts
    180
    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;

    Regards
    Ben de Boer

  3. #3
    Join Date
    May 2002
    Posts
    6

    Question

    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.
    Regards,
    Sultan.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width