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!

how to fire sql query conditionally?

RMukherjeeOct 30 2012 — edited Jul 23 2013
Hi all,
I want a select query to fire conditionally.
for example
I want this:

select case when &a>2 then
select 2 from dual
else when &a<2 then
select 3 from dual
end
from dual;

when variable a is greater than 2 then "select 2 from dual" query will fire
and when variable a is less than 2 the "select 3 from dual " query will fire.

how to do this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 20 2013
Added on Oct 30 2012
13 comments
3,707 views