Im doing an assignment for class, redo a previous assignment we did using SQL PLUS and do it in PLSQL. I finished the assignment using a "regular cursor. (cursor a is select.......) But he mentioned another type of cursor called (at least what he calls it, "Ref-Cursor"). And from what he said, using a Ref-Cursor you can predefine column headings outside of the PLSQL, so that the query printed in PLSQL will not lose its column formatting. Now, I tried this with his example, and it did not work. I am just wondering if anyone here knows anything about this and if this is true or not. If it is please explain. Also Here is the code for the example given to us:

Verified (by me) of the output in SQL PLUS
First Last Employee Total
Name Name Territory Sales
---------- -------------------- ------------------ ------------
Andrew Fuller Westboro $185,395.12
Anne Dodsworth Hollis $86,566.60
Janet Leverling Atlanta $225,605.47
Laura Callahan Philadelphia $143,950.86
Margaret Peacock Rockville $275,109.98
Michael Suyama Phoenix $83,673.45
Nancy Davolio Wilton $215,717.79
Robert King Hoffman Estates $151,602.19
Steven Buchanan Providence $81,745.85
(This post might not format this right but imagine that everything lines up. There are four columns)

Now here is the code in PLSQL to supposedly return the same results w/ the column headings.

set serveroutput on;
declare
type c_type is ref cursor;
c c_type;
type rec_type is record(firstname varchar2(10), lastname varchar2(20),
tdescription varchar2(50), total number);
rec rec_type;
begin
open c for 'SELECT E.FIRSTNAME, E.LASTNAME, EMPT.TDESCRIPTION,
SUM(P.UNITPRICE * OD.QUANTITY) TOTAL
FROM EMPLOYEES E, ORDERS O, ORDERDETAILS OD, PRODUCTS P,
(SELECT E.EMPLOYEEID, RTRIM(T.TERRITORYDESCRIPTION) TDESCRIPTION
FROM EMPLOYEES E, TERRITORIES T,
(SELECT EMPLOYEEID, TERRITORYID
FROM
(SELECT EMPLOYEEID,
TERRITORYID,
ROW_NUMBER() OVER (PARTITION BY EMPLOYEEID ORDER BY EMPLOYEEID NULLS
LAST) "ROWNUMBER"
FROM EMPLOYEESTERRITORIES)
WHERE ROWNUMBER = 1) ET
WHERE E.EMPLOYEEID = ET.EMPLOYEEID
AND ET.TERRITORYID = T.TERRITORYID) EMPT
WHERE EMPT.EMPLOYEEID = E.EMPLOYEEID
AND E.EMPLOYEEID = O.EMPLOYEEID
AND O.ORDERID = OD.ORDERID
AND OD.PRODUCTID = P.PRODUCTID
GROUP BY E.FIRSTNAME, E.LASTNAME, EMPT.TDESCRIPTION';

loop
fetch c into rec;
exit when c%notfound;
dbms_output.put_line(rpad(rec.firstname, 10)||' '||rpad(rec.lastname,
20)||' '||rpad(rec.tdescription, 18)||' '||lpad(rec.total, 15));
end loop;
end;
/
What i tried to do is define the columns before the PLSQL statements and running it. It runs, but does not have the column headings. I know that I can make column headings in PLSQL dbms_output, but My professor was saying that this is an "easier" way, that requires less code, that in turns means less typing for me. So if you can do this, what is it that is wrong with this example?

Any Ideas or answers would be great!
Thanks.