No Data Found Exception in bulk updates
I am trying to catch no data found exception in bulk updates when it does not find a record to update in the forall loop.
OPEN casualty;
LOOP
FETCH casulaty
BULK COLLECT INTO v_cas,v_adj,v_nbr
LIMIT 10000;
FORALL i IN 1..v_cas.count
UPDATE tpl_casualty
set casualty_amt = (select amt from tpl_adjustment where cas_adj = v_adj(i))
where cas_nbr = v_nbr(i);
EXCEPTION WHEN NO_DATA_FOUND THEN dbms_output.put_line('exception')
I get this error at the line where i have exception:
PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
begin case declare end exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe
Can someone pls direct me on how to get around this?
If I do not handle this exception, the script fails when it attempts to update a record that does not exist and the error says : no data found exception.
Thanks for your help.
Edited by: user8848256 on Nov 13, 2009 6:15 PM