Solved

Disable No_Data_Found Exception in Pl-SQL block

Posted on 2014-07-19
6
646 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bulk insert into global temporary table 2 63
Error executing command from server 6 42
history tablespace temp usage 2 31
Query Records that don't match 8 34
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

920 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

15 Experts available now in Live!

Get 1:1 Help Now