-----------------------------------------------------------------/
-- PL/SQL: Anonymous block (Example 4.4.1)                      -
-- Chapter 4; Oracle Programming -- A Primer                    -
--            by R. Sunderraman                                 -
-----------------------------------------------------------------

DECLARE
  TYPE customers_table IS TABLE  OF customers%ROWTYPE 
       INDEX BY BINARY_INTEGER;

  c_table customers_table;
  CURSOR c IS select cno,cname,street,zip,phone
              from   customers;
  c_rec c%ROWTYPE;
  i BINARY_INTEGER;
BEGIN
  i := 1;
  FOR c_rec in c LOOP
    EXIT WHEN c%NOTFOUND;
    c_table(i) := c_rec;
    i := i + 1;
  END LOOP;
  for i in 1..c_table.count loop
    DBMS_OUTPUT.PUT_LINE('c_table(' || i || ').cname = ' || c_table(i).cname);
  end loop;
END;
/
