I am not sure why my 2nd DBMS_OUTPUT.OUT_LINE doesn't print out my list? I recieve anonymous block completed and the headings (RANK: BABY NAMES: ) print out however my requested list does not. Here is my code:
SET SERVEROUTPUT ON
SET VERIFY OFF;
DECLARE
V_SEARCH VARCHAR2(20):= '&SV_SEARCH';
V_ROWS NUMBER(11) := '&SV_ROWS';
CURSOR C_NAME IS
SELECT RANK() OVER (ORDER BY CODE DESC)
FROM (SELECT * FROM "NAME_LIST" WHERE "NAMES" LIKE (V_SEARCH)
ORDER BY CODE DESC)WHERE ROWNUM = V_ROWS;
R_NAME C_NAME%ROWTYPE;
BEGIN
OPEN C_NAME;
DBMS_OUTPUT.PUT_LINE('RANK: BABY NAMES:');
LOOP
FETCH C_NAME INTO R_NAME;
EXIT WHEN C_NAME%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(' '||V_ROWS||' '||V_SEARCH);
END LOOP;
CLOSE C_NAME;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error');
END;
As a result I receive this as my output: anonymous block completed RANK: BABY NAMES: