Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

Oracle PL/SQL Case statement

Can I perform more than one operation for a case?

CASE V_UsrChoice
   WHEN 1
            THEN
                     SELECT A from dual
                     SELECT A1 from dual
   WHEN 2
            THEN      
                    SELECT B from dual
                    SELECT B1 from dual
END CASE
Avatar of Phillip Burton
Phillip Burton

Don't believe so.

Why not:

CASE V_UsrChoice
   WHEN 1
            THEN A
   WHEN 2
            THEN  B
END CASE as first,
CASE V_UsrChoice
   WHEN 1
            THEN A1
   WHEN 2
            THEN  B1
END CASE as second
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dovberman

ASKER

Thanks,

I have not yet built the SQL statements and wanted to simplify the question.

This is just part of a more complex PL/SQL function.

It's good to know that a case structure can be used to execute multiple SQL statements for a single case.
Excellent.

Thanks,
just as a comment..

a "case EXPRESSION" would not allow those multiple operations

a "case STATEMENT" will

Not sure if Oracle's documentation makes that distinction but it exists in other products.