Question

Asked on 2010-08-07 at 23:14:42ID: 26791700

Can we use multiple exceptions in pl/sql?

by: cutie_smily500

Rating7.1Very Good

Here is my requirement. If I get more than one row on first name and last name join then I have to see if there is a match on the middle initial. After looking at the middle initial if there is no match found then throw an error no data found else throw an oracle error.
I did something like below and wanted to know if there is a better way of handling this.

I also like to know if we can use multiple exceptions in one begin block. Something like this

begin
----
----
exception
when too_many rows then
select.............;

if ....then...else..;
exception when no_data_found then
........
exception when others then
select ----
---;

DECLARE
l_tmp_mem member.mem_id%type;
l_tmp_sub member.sub_id%type;

BEGIN

SELECT mem_id, sub_id
into l_tmp_mem, l_tmp_sub
from member m
where lastname = p_last_name
and firstname = p_frst_name;

Exception
WHEN TOO_MANY_ROWS THEN
	SELECT mem_id, sub_id
	into l_tmp_mem, l_tmp_sub
	from member m
	where lastname = p_last_name
	and firstname = p_frst_name
	and middlename = p_mdle_nm;

WHEN NO_DATA_FOUND THEN
	dbms_output.put_line('no match found');

WHEN OTHERS THEN
	dbms_output.put_line('ORACLE ERROR' || SQLERRM);
END;
                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:

Select allOpen in new window

  1. pl/sql procedure to show table row counts
    I would like to create a text or even a table that contains the row counts of tables owned by specific schemas in my database. I pulled a query from another question on EE but it's not working for me. No errors but the table doesn't get populated with the information.
  2. PL/SQL Blank Value in final loop
    I am a novice PL/SQL scripter. I am trying to figure out an efficient & easy way to allow an authorized user to drop sequences for specific schemas before an IMPDP is performed in a Windows environmtn. This is because the IMPDP doesn't overlay sequences and it's causing the user some angst. The user can pass as many schema names as t…
  3. Building Temporary Table (ResultSet) In A Stor…
    I was tasked to develop a report, with a design that is impossible (to my knowledge) to implement using simply SQL. My thought is that I should be able to create a Store Procedure (SP) that will pull out a large portion of data, loop through each record, massaging the data down into a format that can easily be used by the reporting tool. Using MS/SQL…
  4. Group the Member and his associates with a diff…
    Hello All, I have a table 'MEMBERS' which has all the details of the members. This table has certain columns like SBSB_CK, MEME_CK, MEME_SFX, MEME_REL, MEME_LAST_NAME, MEME_FIRST_NAME. Lets take the first example highlighted in BLUE. These two records have same SBSB_CK , but MEME_CK is distributed. The first rec…
  5. VC++ ADO and stored procedure
    Hi, I am migrating a VC++/SQL server app to using Oracle. The database access is implemented using ADO classes, and I have a problem very much like http://www.oraclesolved.com/general/Q_25451408-oracle-stored-procedures-ADO-and-VC.jsp. The answer to that thread is not relevant to the problem, as I have the same…

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
PL / SQL
Tags
Participating Experts
4
Solution Grade
A

Replies

 by: acieeed

Posted on 2010-08-08 at 01:58:12ID: 34781946

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: riazpk

Posted on 2010-08-08 at 22:12:25ID: 34781947

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by:

Posted on 2010-08-09 at 08:18:42ID: 34781948

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: nav_kum_v

Posted on 2010-09-08 at 00:43:50ID: 34781949

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

  1. slightwv

    2,000

    0 points yesterday

    Profile

BrowseBecome an Expert