For this code:
DECLARE
v_APPL_ID NUMBER(10,0) := 0;
v_ADMIN_PHS_ORG_CODE VARCHAR2(2 BYTE) := ' ';
v_SERIAL_NUM NUMBER(6,0) := 0;
v_Proj_Appl_Rec Proj_Appl_Rec;
v_Proj_Appl_Tab Proj_Appl_Tab := Proj_Appl_Tab();
v_Proj_Appl_Cur SYS_REFCURSOR;
v_cnt NUMBER := 0;
GrantApplications_CUR SYS_REFCURSOR;
BEGIN
ireport_portfolios.GetPortfolioAppsAndProjects(
null, 190, 'DYNAMIC', null, v_Proj_Appl_Cur);
--dbms_output.put_line('appl_id' || chr(9) || 'ic' || chr(9) || 'serial_num');
LOOP
FETCH v_Proj_Appl_Cur
INTO v_APPL_ID, v_ADMIN_PHS_ORG_CODE, v_SERIAL_NUM;
EXIT WHEN v_Proj_Appl_Cur%NOTFOUND;
v_Proj_Appl_Tab.extend;
v_cnt := v_cnt + 1;
v_Proj_Appl_Tab(v_cnt) := Proj_Appl_Rec(v_APPL_ID, v_ADMIN_PHS_ORG_CODE, v_SERIAL_NUM);
--dbms_output.put_line( v_APPL_ID || chr(9) || v_ADMIN_PHS_ORG_CODE || chr(9) || v_SERIAL_NUM);
END LOOP;
CLOSE v_Proj_Appl_Cur;
OPEN GrantApplications_CUR FOR
WITH Appls_CTE
AS
(
SELECT DISTINCT
pa.Appl_Id
FROM TABLE(v_proj_appl_tab) pa
)
SELECT ga.appl_id, council_meeting_date
FROM Appls_CTE ac
JOIN grant_appls ga
ON ac.appl_id = ga.appl_id;
RETURN GrantApplications_CUR;
END;
it runs fine if I comment out the RETURN statement at the bottom. But all I see is: anonymous block completed. So I added the Return statement and now I get:
Error report - ORA-06550: line 41, column 9: PLS-00372: In a procedure, RETURN statement cannot contain an expression ORA-06550: line 41, column 9: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
I tried taking the CTE out and just joining to "TABLE(v_proj_appl_tab) pa". But I get the same error.
What is the last step here to be able to see the results? How do you return results like this from a simple query window without having to write a Package PROC?
I tried running this from the tip below: DBMS_SQL.RETURN_RESULT(GrantApplications_CUR);
Now I get this error:
Error report - ORA-06502: PL/SQL: numeric or value error ORA-06512: at "LINK_OD_IREPORT.IREPORT_PORTFOLIOS", line 217 ORA-06512: at "LINK_OD_IREPORT.IREPORT_PORTFOLIOS", line 83 ORA-06512: at line 12 06502. 00000 - "PL/SQL: numeric or value error%s" *Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2). *Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints. Now I get this error: