I have Couple of scenarios 1) need to read the value of a column from three different tables in a predefined order and only 1 tabel will have the data 2) read data from table1 if records are present for criteria given else Read Data from Table2 for Given Criteria
In Oracle Stored Procedures The way these are being handled right now is to first get the count for a given query into a variable and if the count > 0, then we execut the same query to read the actual data as in
select count(*) from table1 into v_count
if v_count > 0
then
select data into v_data from table1
end if;
Return v_data
This is being done to avoid the no_data_Found exception, other wise i would need three exception handler blocks to catch the no_data_found exception for each table access
Currently i am reimplementing this with Cursors so that i have something like this
cursor C1 is
select data from table1;
Open C1
Fetch C1 into v_data
if C1%FOUND
then
Close C1
Return v_data
End If
I wanted to find out which one is better from a performance point of view the one with Cursors or the one which does a Select into a variable and has three no_data_found Exception blocks. I dont want to use the Current Two Stage query process which we have currently