Click to See Complete Forum and Search --> : fetch all rows


AYYOUT
04-17-2006, 07:13 AM
Hi,
please who can tell me why my cursor fetch me only the data of first row.
DECLARE
/* Explicit declaration of a cursor */
CURSOR CUR IS
SELECT ALL ID_BOSS,CNSS_BOSS
FROM MATRICULE_CNSS_BOSS;
BEGIN
/* Check to see if cursor is already open. If not, open it. */
IF NOT cur%ISOPEN
THEN
OPEN cur;
END IF;
FETCH cur INTO :BOSS,:CNSS;
CLOSE cur;
END;
i like to fetch all the rows :confused: thx

LKBrwn_DBA
04-17-2006, 10:30 AM
The following statement will only fetch ONE row:
FETCH cur INTO :BOSS,:CNSS;
In order to fetch next rows you need LOOP..END LOOP. :rolleyes:
I recommend you read (http://www.jargon.net/jargonfile/r/RTFM.html) the manual (http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/04_struc.htm#585) :D

rigatoni
04-27-2006, 01:14 PM
BEGIN

for cur in (SELECT ID_BOSS, CNSS_BOSS
FROM MATRICULE_CNSS_BOSS)
loop

-- do some processing
dbms_output.put_line(cur.id_poss || ' / ' || cur.cnss_boss);

end loop;

END;

.. and as LKBrwn_DBA says the details are in the manual.