Solved

Disable No_Data_Found Exception in Pl-SQL block

Posted on 2014-07-19
6
641 Views
Last Modified: 2014-07-21
Hi,

In my Pl-SQL block there are 20 different SELECT queries extracting data from different tables.  And the requirement is that all queries are independent to each other, means that if any SQL statement gives error the procedure should continue for next SELECT statement instead of STOPPING procedure at EXCEPTION level.  I know that we can use BEGIN and END for each independent query to call its own EXCEPTION block.  But is there any way to disable NO__DATA_FOUND exception for the said PL/SQL block so all the queries run continuously without using their separate BEGIN and END block.

Thanks and Regards,
0
Comment
Question by:Sudees
6 Comments
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 300 total points
ID: 40207222
You could try adding a dummy column at the end of each select that selects some string from dual. That way you always get a record from the select (but filled with one or more NULLs).

Like this:

before: select a,b,c from d;
after: select a,b,c, (select 'some_string' d from dual) from d;
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 100 total points
ID: 40207982
Nested pl/sql blocks with their own exception handler is the correct way to do this.
0
 

Author Comment

by:Sudees
ID: 40207983
Yes, I know about that but the queries are too much so NESTED pl/sql block makes the code complex so I want to ask, if there is any way to disable any exception in PL/SQL block
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40207997
I do not know of a way to disable exceptions for an entire block of code.

I feel you will either need to edit the code and do things the way they are supposed to be done or edit the selects as suggested above so they always return something.
0
 
LVL 16

Assisted Solution

by:Wasim Akram Shaik
Wasim Akram Shaik earned 100 total points
ID: 40208248
One way is to go for the count..

first count the record set output of the query, if its greater than 0(obviously if 0 means no data found) then you can execute the query..

But here you have to write a statement again which is simply a duplicate of actual query where in its just checking the count.

as experts suggested.. nested pl/sql blocks are the efficient way to do this..
0
 

Author Closing Comment

by:Sudees
ID: 40209416
Thanks for your suggestions..
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now