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 use anonymous block in select statement

900115Mar 30 2012 — edited Mar 30 2012
Hello Experts.

I have one requirement which i can resolve using anonymous block in plsql. But i want implement it in select query only.
Database: Oracle 11.2.0

select count(*) from emp where name='xyz' and sal=50
if count(*)>0
then
select dept,sector from emp where name='xyz' and sal=50

here i dont have any primary key.

How can i achieve above using sql query not plsql. Here is one sloution which i have got but its not satisfying above requiremnt as i dont have any primary key columns

select toll_number from toll_details
where toll_id =(select toll_id from toll_details where toll_new_id='5263655214' group by toll_id having count(*)>0)

here toll_id is primary key, so used group by. But how to do this in my above requirement as i dont have primary key.

Appreciate any help on this.
Thank you
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 27 2012
Added on Mar 30 2012
10 comments
2,163 views