Solved

Disable No_Data_Found Exception in Pl-SQL block

Posted on 2014-07-19
6
656 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 38

Accepted Solution

by:
Gerwin Jansen, EE MVE 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

839 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