Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: a pl/sql question

RE: a pl/sql question

From: Davey, Alan <Alan.Davey_at_encodasystems.com>
Date: Fri, 30 Apr 2004 10:19:30 -0600
Message-ID: <7487761A46884449834CAD636919C07B0120CEC2@nycexc02.Denver.cjds.com>


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_at_state.pa.us] 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_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Fri Apr 30 2004 - 11:19:16 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US