Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No Data Found Exception in bulk updates

JambalahotNov 13 2009 — edited Nov 16 2009
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
This post has been answered by Tubby on Nov 14 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2009
Added on Nov 13 2009
3 comments
4,443 views