Tuesday, August 9, 2011

6502: PL/SQL: numeric or value error

in PL/SQL if we iterate a table and use follwing syntax
FOR i IN v_mac_tbl.FIRST .. v_mac_tbl.LAST LOOP
blar... with v_mac_tbl(i)
end loop

v_mac_tbl is a table of some sequence type

the table is fill by a fetch bulk collect into.

if the source cursor is empty,then the table is empty,so reference of v_mac_tbl(i) will throw SQLException,it sames like for loop will execute at least one time even table is empty.
the solution is use a if before For loop by checl v_mac_tbl.count >0.

No comments:

Post a Comment