Replace
FOR i IN port_arr.FIRST .. port_arr.LAST
with:
FOR i IN 1 .. port_arr.COUNT
If no records are deleted the array will not be initialized and port_arr.FIRST
and port_arr.LAST
will return null, which will raise the exception ORA-06502: PL/SQL: numeric or value error
. COUNT
is always safe to use, even on a collection that has not been initialized.