rem ----------------------------------------------------------------------- rem Filename: plstable.sql rem Purpose: Example: how to populate a PL/SQL Table from a cursor rem Date: 09-Apr-1999 rem Author: Frank Naude, Oracle FAQ rem ----------------------------------------------------------------------- set serveroutput on declare -- Declare the PL/SQL table type deptarr is table of dept%rowtype index by binary_integer; d_arr deptarr; -- Declare cursor type d_cur is ref cursor return dept%rowtype; c1 d_cur; i number := 1; begin -- Populate the PL/SQL table from the cursor open c1 for select * from dept; loop exit when c1%NOTFOUND; fetch c1 into d_arr(i); i := i+1; end loop; close c1; -- Display the entire PL/SQL table on screen for i in 1..d_arr.last loop dbms_output.put_line('DEPTNO : '||d_arr(i).deptno ); dbms_output.put_line('DNAME : '||d_arr(i).dname ); dbms_output.put_line('LOC : '||d_arr(i).loc ); dbms_output.put_line('---------------------------'); end loop; end; /