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.
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:
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.
Many times a DBA may want to replicate a user from one system to another and migrate that same password,such as refreshing a production system ...
Sometimes you need to get data from a server into your database or from your database into a remote server. Learn how to use FTP to ...
Oracle introduced the UTL_SMTP package with the release of 8i back in 1999, but up through the current version (11.2.0.1) available on OTN...
New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...
Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...
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 ...
"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
Know a thing or two about Oracle? Join our team of experts today.
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.