Returning a sys_refcursor from an explicit cursor [message #629733] |
Mon, 15 December 2014 13:56 |
tmcallister
Messages: 107 Registered: December 2007
|
Senior Member |
|
|
I'm trying to return a sys_refcursor from an explicit cursor rather than an implicit one; but the syntax is destroying me and google isn't my friend today.
Here are some trivial examples. I don't like the first one in my code since there is some pretty complicated logic and long queries and mixing them together is ugly. I don't like the second because I have a general dislike for dynamic queries unless they are doing something extremely useful, and this doesn't qualify. I don't like the third since I can't figure out the syntax.
Help please? Thanks!
/* Formatted on 12/15/2014 12:50:37 PM (QP5 v5.256.13226.35538) */
CREATE OR REPLACE PROCEDURE rc1(rc OUT SYS_REFCURSOR) AS
BEGIN
OPEN rc FOR
SELECT ROWNUM
FROM DUAL
CONNECT BY LEVEL < 11;
END;
/
CREATE OR REPLACE PROCEDURE rc2(rc OUT SYS_REFCURSOR) AS
sql_stmt VARCHAR2(100) := 'SELECT ROWNUM
FROM DUAL
CONNECT BY LEVEL < 11';
BEGIN
OPEN rc FOR sql_stmt;
END;
/
CREATE OR REPLACE PROCEDURE rc3(rc OUT SYS_REFCURSOR) AS
CURSOR c1 IS
SELECT ROWNUM
FROM DUAL
CONNECT BY LEVEL < 11;
BEGIN
NULL;
END;
/
|
|
|
|
|