PL/SQL Sample Program # 4

rem  This program displays the data in the STOCK table

set serveroutput on size 20000

declare

 cursor stock_crsr is
  select stocksymbol, stockname, currentprice
   from stock
   order by stocksymbol;

begin
--  Display headings:

 dbms_output.put_line('Stock      Stock               Current');
 dbms_output.put_line('Symbol     Name                 Price');
 dbms_output.put_line('--------------------------------------');

--  Loop through rows in the Stock table:
 for stock_row in stock_crsr loop
     dbms_output.put_line(stock_row.stocksymbol || '        '
                        || stock_row.stockname
                        || to_char(stock_row.currentprice, '999.99'));
 end loop;

end;
/