Oracle - pl sql selecting from SYS_REFCURSOR
- by Einstein
I have a function that returns a SYS_REFCURSOR that has a single row but multiple columns. What I'm looking to do is to be able to have a SQL query that has nested sub-queries using the column values returned in the SYS_REFCURSOR. Alternative ideas such as types, etc would be appreciated. Code below is me writing on-the-fly and hasn't been validated for syntax.
--Oracle function
CREATE DummyFunction(dummyValue AS NUMBER) RETURN SYS_REFCURSOR
IS
RETURN_DATA SYS_REFCURSOR;
BEGIN
OPEN RETURN_DATA
SELECT
TO_CHAR(dummyValue) || 'A' AS ColumnA
,TO_CHAR(dummyValue) || 'B' AS ColumnB
FROM
DUAL;
RETURN RETURN_DATA;
END;
--sample query with sub-queries; does not work
SELECT
SELECT ColumnA FROM DummyFunction(1) FROM DUAL AS ColumnA
,SELECT ColumnB FROM DummyFunction(1) FROM DUAL AS ColumnB
FROM
DUAL;