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!

Stored Procedure Result Set from multiple select statements

user2269823Mar 30 2009 — edited Apr 2 2009
Friends,

I need to return a result set from multiple select statements where the results from each select statement are appended to the previous results. This is for a complex report I'm required to develop.

In my test stored procedure, I can successfully return a result set, but only for the last select statement in the loop. Any help would be appreciated.

In the following scenario, I have two departments, IT and HR, but I only receive results from the HR department.

CREATE OR REPLACE
PROCEDURE employee
(
c_out OUT sys_refcursor )
AS
BEGIN
FOR idx IN
(SELECT department FROM department
)
LOOP
OPEN c_out FOR SELECT employee, department FROM employee WHERE department = idx.department;
END LOOP;
END employee;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2009
Added on Mar 30 2009
17 comments
5,611 views