RE: a pl/sql question

  • From: "Davey, Alan" <Alan.Davey@xxxxxxxxxxxxxxxxx>
  • To: "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 30 Apr 2004 10:19:30 -0600

Hi Donald,

My example was only meant to show that sql%notfound would never be hit.  One
of these days I'll learn to add comments to my code ;-)

Regards,

-----------------------------------------
Alan Davey
Tech Lead
Oracle 9i OCA; 3/4 OCP
w) 973.267.5990 x458
w) 212.295.3458



-----Original Message-----
From: Freeman, Donald [mailto:dofreeman@xxxxxxxxxxx]
Sent: Friday, April 30, 2004 11:12 AM
To: Oracle-L (E-mail)
Subject: FW: a pl/sql question



>       The difference in this case is your example selects into a variable
=
instead of directly updating the table.  I followed up on this by =
reading the PL/SQL manual (RTFM?) and there are several warnings about =
using cursor attributes including one similiar to your example. What I =
wrote is only good for the narrow usage I showed ;-).  On page 6-40 of =
the 9.2 PL/SQL Users Guide is:
>=20
>                       "If a SELECT INTO statement fails to return a row,
PL/SQL raises =
the predefined
>                       exception NO_DATA_FOUND whether you check %NOTFOUND
on the next =
line or not.
>                       Consider the following example:
>                       BEGIN
>                       ...
>                       SELECT sal INTO my_sal FROM emp WHERE empno =3D
my_empno;
>                       -- might raise NO_DATA_FOUND
>                       IF SQL%NOTFOUND THEN -- condition tested only when
false
>                       ... -- this action is never taken
>                       END IF;
>                       The check is useless because the IF condition is
tested only when =
%NOTFOUND is
>                       false. When PL/SQL raises NO_DATA_FOUND, normal
execution stops and =
control
>                       transfers to the exception-handling part of the
block."
>       =20
>       > An update that doesn't update any records is not an exception =
error.
>       >=20
>       > Trying to select multiple record values or no record values=20
>       > when you expect
>       > to always get one and only one value is an exception, so that=20
>       > logic won't
>       > work in this situation.
>=20


"This information in this e-mail is intended solely for the addressee and
may contain information which is confidential or privileged.  Access to this
e-mail by anyone else is unauthorized.  If you are not the intended
recipient, or believe that you have received this communication in error,
please do not print, copy, retransmit, disseminate, or otherwise use the
information. Also, please notify the sender that you have received this
e-mail in error, and delete the copy you received."

----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: