Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Merging result set of two separate queries

2795121Jan 26 2015 — edited Jan 26 2015

I'm converting a procedure from Microsoft's TSQL into Oracle's PL/SQL.

Currently, the procedure does two select queries. They look like so:

    PROCEDURE procName       

      @system_id  int,         

      @user_id      int,                

    AS         

    SELECT  lots of fields

    FROM     lots of tables

    WHERE  id = system_id

    SELECT  lots of different fields

    FROM     lots of different tables

    WHERE  id = system_id

That is really all there is to the TSQL procedure. Each query's selected fields are completed different to one another (not a single common column). When this procedure is called from the code, each field can be referenced and the calling program simply knows where to get the result from.

In converting it to Oracle, I've had to tinker with it. I've created two separate sys ref cursors now, one to hold the result of each query. However, how can I amalgamate these into a single result set and return them to the user?

Key info:

1. Two separate queries.

2. All fields in each query are unique (i.e. nothing in Query 1 appears in Query 2 and vice versa).

3. Need to return is as a single, flat result set.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2015
Added on Jan 26 2015
6 comments
15,243 views