snippetMinor
How to return a result set from oracle procedure ?
Viewed 0 times
resultoraclereturnprocedurehowfromset
Problem
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 :
I tried this but this seems plain wrong!
what is wrong?
suppose i want to return a table from a simple select statement such as this :
Select * from tblTestI 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?
Solution
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:
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;Code Snippets
CREATE OR REPLACE
PROCEDURE ProcSelectEveryThing(cursor_ OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cursor_ FOR
SELECT * FROM tblTest;
END;Context
StackExchange Database Administrators Q#68295, answer score: 4
Revisions (0)
No revisions yet.