How to execute a procedure having multiple cursors as output in oracle.
CREATE OR REPLACE PROCEDURE TC_OWNER.usp_GetGEGAllDataBySecurityID(
p_SecurityID NUMBER,
cur1 OUT sys_refcursor,
cur2 OUT sys_refcursor,
cur3 OUT sys_refcursor,
cur4 OUT sys_refcursor,
cur5 OUT sys_refcursor)
AS
v_EffectiveDate TIMESTAMP(3);
v_CompanyID NUMBER(10);
BEGIN
SELECT MAX(EffectiveStartDate) INTO v_EffectiveDate
FROM tblGEGSecurityDtls
WHERE SecurityId = p_SecurityID AND SYSDATE BETWEEN EffectiveStartDate
and EffectiveEndDate;
SELECT CompanyID INTO v_CompanyID
FROM tblGEGSecurityDtls
WHERE SecurityId = p_SecurityID AND EffectiveStartDate =
v_EffectiveDate;
usp_GetGEGSecurityDtls(p_SecurityID,cur1);
usp_GetGEGRecommendations(p_SecurityID,cur2);
usp_GetGEGCompanyDtls(v_CompanyID,cur3);
usp_GetGEGSectorRegionData(v_CompanyID,null,cur4);
usp_GetGEGCompanyDivisionData(v_CompanyID,null,cur5);
END;
Here anything starting with usp_ denotes a procedure. Each of the procedure returns a table.
The same can easily be achieved in sql but i am unable to execute this in oracle.
Edit : As per the answer given by vc74 i tried the below code to print all the five tables but it is throwing error:
declare
lcur1 sys_refcursor;
lcur2 sys_refcursor;
lcur3 sys_refcursor;
lcur4 sys_refcursor;
lcur5 sys_refcursor;
begin
usp_GetGEGAllDataBySecurityID(
p_SecurityID => 457,
cur1 => lcur1,
cur2 => lcur2,
cur3 => lcur3,
cur4 => lcur4,
cur5 => lcur5
);
end;
print lcur1;
print lcur2;
print lcur3;
print lcur4;
print lcur5;
How to print all the tables in the output window?