3

How can i return a result set from a stored procedure in oracle ?
suppose i want to return a table from a simple select statement such as this :

Select * from tblTest

I tried this but this seems plain wrong!

CREATE OR REPLACE 
PROCEDURE ProcSelectEveryThing(cursor_ OUT TYPES.REF_CURSOR)
AS
BEGIN
OPEN cursor_ FOR
 SELECT * FROM "tblTest"; 
END;

what is wrong?

asked Jun 16, 2014 at 8:09
0

2 Answers 2

4

You don't need a return statement, because it is using OPEN and FOR... It is the same like RETURN...

The error is in the name of the table, you put it in "" double quotes. Remove that, use simply the name of the table, and use the type SYS_REFCURSOR like this:

CREATE OR REPLACE 
PROCEDURE ProcSelectEveryThing(cursor_ OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cursor_ FOR
 SELECT * FROM tblTest; 
END;
RLF
14k2 gold badges35 silver badges47 bronze badges
answered Apr 29, 2016 at 18:01
2

You're missing a RETURN statement in your PL/SQL. Check out the answer here. There are any number of sites which can provide a quick response to this query. I recommend that you download SQLDeveloper and look at some of the system supplied stuff and check out the docco, starting here. SQLDeveloper is really great - and it's free!

answered Jun 16, 2014 at 8:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.