ro.nin
ro.nin

Reputation: 121

PLSQL : If variable IN subquery

Is it possibile in PL/SQL function something like

IF xVar IN (SELECT yVar
            FROM....)
THEN...

this? Thank you

Upvotes: 4

Views: 7735

Answers (2)

Vlad Dekhanov
Vlad Dekhanov

Reputation: 1086

You can use FOR-IN with your implicit cursor. I know only IF-THEN-ELSE operator with IF expression.

Upvotes: 0

Joel
Joel

Reputation: 196

No, you will probably have to so something like

select count(*) 
into foo 
from blah
where yVar = xVar

if foo > 0 then ...

Or you could make a function that returns boolean if this is something you'd use often

Upvotes: 3

Related Questions