oracle - While using Table Type data type in PL/SQL getting 'NO DATA FOUND' error -


here defining table type variable , trying insert rows variable using loop unable insert data . getting data not found error... please let me know whats wrong cod.

    declare type t_emp   table of emp%rowtype index binary_integer;   v_emp t_emp ;   v_min_emp emp.empno%type;   v_max_emp emp.empno%type; begin   --v_min_emp:=7369;   --v_max_emp:=7934;   select min(empno) v_min_emp emp;   select max(empno) v_max_emp emp;    in v_min_emp..v_max_emp   loop     select * v_emp(i) emp empno=i;   end loop; end; 

in code i index. steps through bounds monotonically. if minimum empno 1234 , maximum empno 5678 values of i 1234, 1235, 1236 ... 5676, 5677, 5678.

but want do, because empno sparse array, missing numbers. if have no row in emp empno=1235 query throw no_data_found.

what's solution? use bulk collect instead:

select *  bulk collect v_emp emp ; 

that select rows in table, , more efficient well.


Comments