PDA

View Full Version : how to ignore "No Data Found" error during procedure.


Guest
05-11-2005, 09:28 AM
I am creating a procedure in Oracle 9i, and during my procedure I loop
through a set of numbers (ie 1-10) and retrieve a number from tableA
based on what number we are in the loop (tableA.dbid = 1). Say we get
to number 10 but dbid value of 10 does not exist in tableA, then Oracle
finds no data and stops the procedure and gives the error "No Data
Found". Is there a way in oracle to assign the variable something if
it come accross a No Data Found Error?

Mark C. Stock
05-11-2005, 09:47 AM
<jeffchirco@gmail.com> wrote in message
news:1115832524.915141.237600@z14g2000cwz.googlegroups.com...I am creating a procedure in Oracle 9i, and during my procedure I loop through a set of numbers (ie 1-10) and retrieve a number from tableA based on what number we are in the loop (tableA.dbid = 1). Say we get to number 10 but dbid value of 10 does not exist in tableA, then Oracle finds no data and stops the procedure and gives the error "No Data Found". Is there a way in oracle to assign the variable something if it come accross a No Data Found Error?

i can think of 3 ways to handle it:

1) exception handler (wrap the SELECT in a BEGIN ... EXCEPTION ... END
block)
2) explicit cursor (OPEN .... FETCH ... CLOSE)
3) cursor in-line SELECT for loop (shortcut for #1 and #2, disdained by some
when used for single-row fetches, but simplifies coding -- make sure to add
a comment if using this technique to fetch a single row)
4) ok, may 4 ways... select MAX() or MIN() ... this always returns a row
(but is a somewhat artificial technique and can lead to confusion when
maintaining code)

++ mcs

Guest
05-11-2005, 10:44 AM
Thanks for the quick respons. The exception handler worked perfectly.


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service