Re: NO_DATA_FOUND EXCEPTION

From: <ballpe_at_cnb07v.hhcs.gov.au>
Date: 1995/04/23
Message-ID: <1995Apr23.123002.1_at_cnb07v.hhcs.gov.au>#1/1


In article <3nbutc$4sp_at_news.annex.com>, sanctus2_at_annex.com () writes:
> In PL/SQL, if I do a SELECT INTO or a FETCH that returns 0 records, the
> NO_DATA_FOUND EXCEPTION is raised. That's all well and good but what do
> I do with it? If I write code to only do something if I RETRIEVE
> records, why can't I ignore the NO_DATA_FOUND? It ends up generating an
> error in my trigger and rolls back my transaction.
>
> I want to be able to retrieve no records WITHOUT erroring out my trigger.
>
Jack,

Some old code for you...

      procedure allocate_activity_id is
      begin
        select crs.activity_ids.nextval
        into   :activity_list.activity_id
        from   dual;
        :activity_ctl.activity_id := :activity_list.activity_id;
      exception
        when no_data_found then
          error_message('E','Unable to allocate activity id.'||
                        ' Contact System Administrator.','S',0,0);
          raise form_trigger_failure;
      end;
 

If you want the exception to be handled with a big nothing, use "null". So you'd have

                exception
                  when no_data_found then
                    null;

. Hope this is what you want.
Regards,
-- 

Peter Ball (ballpe_at_cnb07v.hhcs.gov.au)  "These views are mine alone"
Systems Development Officer, Department of Human Services and Health,
Brisbane, Queensland, Australia. Telephone : (07) 360 2637
Post : Information Services Section, GPO Box 9848, Brisbane QLD 4001, AUSTRALIA
Received on Sun Apr 23 1995 - 00:00:00 CEST

Original text of this message