I have a package in oracle that contains one stored procedure. It takes a date as a input and a number as input, and outputs the data into a ref_cursor. The purpose of the stored procedure is to extract all of the "winning numbers" that correspond to a certain input date.
CREATE OR REPLACE PACKAGE GETWINNINGNUMBERSBYDATEPKG IS
TYPE lotgwndate_ref_cursor IS REF CURSOR;
PROCEDURE GetWinningNumbersDATE (lg_wndate IN date, lg_wnwgid IN number, lg_ref OUT
lotgwndate_ref_cursor);
END GETWINNINGNUMBERSBYDATEPKG;
This is the package body. Again, the purpose here is to extract all of the "winning numbers" that correspond to a certain date and "gameid" number. Then, I want to pair the "winning numbers" with the "game name" and "drawing date". (This is to extract records from lottery drawings)
PROCEDURE GetWinningNumbersDATE (lg_wndate IN date, lg_wnwgid IN number, lg_ref OUT
lotgwndate_ref_cursor) IS
BEGIN
OPEN lg_ref FOR
SELECT a.GAMENAME, b.DRAWINGDATE, c.BALLNUMBER
FROM GAMEDETAILS a
INNER JOIN WINNINGRECORDS b
on a.GAMEDETAILSID = b.GAMEDETAILSID
INNER JOIN WINNINGBALLS c
on b.WINNINGRECORDSID = c.WINNINGRECORDSID
WHERE b.DRAWINGDATE = lg_wndate
AND a.GAMEDETAILSID = lg_wnwgid;
END GetWinningNumbersDATE;
END GETWINNINGNUMBERSBYDATEPKG;
Here is the call procedure.
SET SERVEROUTPUT ON size 100000
DECLARE
v_cursor LOTTERYGAMEPKG.lotgwndate_ref_cursor;
v_gamename GAMEDETAILS.gamename%type;
v_drawingdate WINNINGRECORDS.drawingdate%type;
v_ballnumber WINNINGBALLS.ballnumber%type;
BEGIN
GETWINNINGNUMBERSBYDATEPKG.GetWinningNumbersDATE(lg_wndate =>
TO_DATE('06/08/2014','dd/mm/yyyy'), lg_wnwgid => '4', /*date/gamedetailsid #(1-4)*/
lg_ref => v_cursor);
LOOP
FETCH v_cursor
INTO v_gamename, v_drawingdate, v_ballnumber;
EXIT WHEN v_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE
(v_gamename || ',' || v_drawingdate || ',' || v_ballnumber);
END LOOP;
END;
This works, and returns:
NorthstarCash,06-AUG-14,10
NorthstarCash,06-AUG-14,11
NorthstarCash,06-AUG-14,15
NorthstarCash,06-AUG-14,16
NorthstarCash,06-AUG-14,21
However, I want it to return
NorthstarCash,06-AUG-14,10,11,15,16,21
Are there any ways to do this? I have looked at many other questions but none are addressing the same issue as mine. ORACLE 11g