Declare <br/> l_ SQL varchar2 (2000): = 'select deptno, LOC from Scott. dept '; <br/> l_where varchar2 (200); </P> <p> type dept_curtype is ref cursor; <br/> dept_cur dept_curtype; <br/> type dept_rec is record (<br/> deptno varchar2 (200) -- attention the record element order <br/>, Loc varchar2 (200 )); <br/> type dept_tbl is table of dept_rec; <br/> l_dept_tbl dept_tbl; </P> <p> begin <br/> l_where: = 'where deptno =: deptno'; <br/> l_ SQL: = l_ SQL | l_where; <br/> open dept_cur for l_ SQL <br/> using 40 -- using is not necessary <br/>; <br/> fetch dept_cur bulk collect <br/> into l_dept_tbl; <br/> close dept_cur; </P> <p> dbms_output.put_line ('L _ str_tbl.count = '| l_dept_tbl.count); <br/> <l_dept_tbl_loop> <br/> for I in 1 .. l_dept_tbl.count <br/> loop <br/> dbms_output.put_line ('L _ str_tbl ('| I | '). deptno = '| <br/> l_dept_tbl (I ). deptno | ', l_str_tbl (' | I | <br/> '). loc = '| l_dept_tbl (I ). loc); </P> <p> end loop l_dept_tbl_loop; <br/> end; <br/>