Help!!!!!!!! to track exception in one single block for three different select statement...... [message #446457] |
Mon, 08 March 2010 09:55  |
amit.sonar
Messages: 98 Registered: December 2009 Location: Mumbai
|
Member |
|
|
Hi all,
Can anybody tell me how can i track the exception for three select statement in one pl-sql block. here is synario.......
begin
select * from emp where empno=1234; --statement 1
select * from cusotmers where cust_id=125; --statement 2
select * from products where product_id='a-3'; --statement 3
end;
i want to track exception any one for ex no_data_found for all these three different statement.
I know if i put this three statement in three different pl-sql sublock then i can trap it....
how can i trap it in one single block??? Kindly help me on this.
Regards,
Amit Sonar.
|
|
|
|
|
|
Re: Help!!!!!!!! to track exception in one single block for three different select statement...... [message #446596 is a reply to message #446457] |
Tue, 09 March 2010 08:41  |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Assuming that what you want (your question is a little on the incoherent side) is to identify which of your selects raises the exception then you could do this:
declare
v_stmnt pls_integer := 0;
begin
v_stmnt :=1;
select * into <variable> from emp where empno=1234; --statement 1
v_stmnt :=2;
select * into <variable> from cusotmers where cust_id=125; --statement 2
v_stmnt :=3;
select * into <variable> from products where product_id='a-3'; --statement 3
exception
when no_Data_found then
<code to handle exceptions. This code can use v_stmnt to
identify which statement caused the error>
end;
|
|
|