Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

cascading two cursor queries

Gor_MahiaFeb 24 2015 — edited Feb 26 2015

Hi,

i have a situation where i want to query the second cursor/loop only if there is no "record" returned (not found) in the first cursor/ loop

Scenario:

=========

consider a situation where there are 2 backup tables table2 and table3, so using master table1, i'll query table3 only if and only if no record is first found in table2 i.e. if i find at least one record in table2 then i dont need to go to table3

like

FIRST LOOP:

-------------------------

for t in (select * from table1, table2 where table1.id =  table2.user_id) loop

.//something

end loop;

for above loop if no value is returned is when i execute second loop below,

NOTE: its checking if not found then get record(s) from loop second below,

SECOND LOOP:

-------------------------

for t in (select * from table1, table3 where table1.id =  table3.user_id) loop

.//something

end loop;



what is the most efficient approach if iam using pl/sql?


thansk & regards,


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2015
Added on Feb 24 2015
9 comments
469 views