WORKING WITH REF CURSOR
I create and populate the following table: CREATE TABLE plch_tab (item VARCHAR2 (10)) / BEGIN INSERT INTO plch_tab VALUES ('Keyboard'); INSERT INTO plch_tab VALUES ('Mouse'); COMMIT; END; / I then create this function to fetch a row from a cursor variable and return the item: CREATE OR REPLACE FUNCTION plch_getitem ( plch_cur IN SYS_REFCURSOR) RETURN plch_tab.item%TYPE IS lvretval plch_tab.item%TYPE; BEGIN FETCH plch_cur INTO lvretval; RETURN lvretval; END plch_getitem; / Now I need to write a block that will fetch the rows from the table and display both the count of rows fetched and the name of that last item fetched. Here is an almost complete version of this block: DECLARE lvitem plch_tab.item%TYPE; test_cur SYS_REFCURSOR; BEGIN OPEN test_cur FOR SELECT * FROM plch_tab ORDER BY item; /*FETCH*/ DBMS_OUTPUT.put_line ('Count = ' || test_cur%ROWCOUNT); DBMS_OUTPUT.put_line ('