Dovberman
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
Excellent.
Thanks,
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.
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.
CASE EXPRESSION
http://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions004.htm
CASE STATEMENT
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/case_statement.htm
should have looked first, they do!
http://docs.oracle.com/cd/B19306_01/server.102/b14200/expressions004.htm
CASE STATEMENT
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/case_statement.htm
should have looked first, they do!
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