Re: NO_DATA_FOUND EXCEPTION

From: John Blackburn <jb2_at_qdot.qld.gov.au>
Date: 1995/05/11
Message-ID: <3orst7$f77_at_camelot.qdot.qld.gov.au>#1/1


sanctus2_at_annex.com wrote:
> 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.
 

> I'd appreciate any help on this issue.
> Thanx....
 

> Jack Schwartz
> Systems Analyst
> Great Western Bank

Use Explicit cursors:

declare
  data datatype;
  cursor my_cursor is

     select data
     from   table;

begin
  open my_cursor;
  fetch my_cursor into data
  if my_cursor%NOTFOUND then

     null;
  end if;

  .
  .
  .

end;
--
 
John Blackburn                                          Phone: +61 7 2534634
jb2_at_qdot.qld.gov.au                                     Fax:   +61 7 8541194
Received on Thu May 11 1995 - 00:00:00 CEST

Original text of this message