i want to add a sys_refcursor as out parameter in this procedure
CREATE OR REPLACE PROCEDURE APIN
(
ADT APT.A_DATE%TYPE,
DID APT.D_ID%TYPE
)
/* i want to add a sys_refcursor as out parameter in this procedure */
AS
TYPE VRC IS RECORD
(
V_DT DATE,
V_ID NUMBER
);
/declaring the type for ref cursor/
TYPE V_RC IS REF CURSOR RETURN VRC;
/* how can i use this as out parameter along with the in parameters.*/
R V_RC;
RC SYS_REFCURSOR;
V_CNT NUMBER := 0;
V_STATUS VARCHAR2(30);
/* i want to add this variable as column name in the result set*/
V_ST_DT DATE;
V_ED_DT DATE;
BEGIN
V_ST_DT := TRUNC(TO_DATE(ADT,'DD/MM/YY'),'MM');
/*getting first date of the month*/
V_ED_DT := LAST_DAY(V_ST_DT);
/*getting last date of the month*/
LOOP
OPEN RC FOR
/* selecting v_cnt value using ref cursor*/
SELECT MAX(RN) FROM (SELECT ROW_NUMBER()OVER(ORDER BY P_ID) RN FROM APT
WHERE D_ID = DID
AND A_DATE = V_ST_DT);
FETCH RC INTO V_CNT;
IF V_CNT >= 10 THEN
V_STATUS := ' NOT AVAILABLE ON ';
/* is there any way to add this vairable values into the column of the table apt?*/
OPEN R FOR
SELECT A_DATE, D_ID FROM APT
WHERE D_ID = DID
AND A_DATE = V_ST_DT;
DBMS_OUTPUT.PUT_LINE(DID||V_STATUS||V_ST_DT);
/*instead of using dbms_output, i need to get output from select statement*/
ELSE
V_STATUS := ' AVAILABLE ON ';
OPEN R FOR
SELECT A_DATE, D_ID FROM APT
WHERE D_ID = DID
AND A_DATE = V_ST_DT;
DBMS_OUTPUT.PUT_LINE(DID||V_STATUS||V_ST_DT);
/*instead of using dbms_output, i need to get output from select statement*/
END IF;
V_ST_DT := V_ST_DT + 1;
/*incrementing date variable to check next date*/
EXIT WHEN V_ST_DT > V_ED_DT;
END LOOP;
CLOSE RC;
/*closing the ref cursor*/
END;
/