ORACLE CASE
from OTN : case
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/case_statement.htm#LNPLS01304
1. CASE
A.
프로그래밍 언어의 CASE 와 동일한 역할을 한다.
B. literal, variable,
function call, 모든종류의 expression 을 사용할 수 있다.
2. 예제
SQL> get cas
1
declare
2
tmp number;
3
region_name varchar2(40);
4
begin
5
select region_id into tmp from regions where region_id = 3;
6
case
7
when tmp = 1 then region_name := 'Europe';
8
when tmp = 2 then region_name := 'Americas';
9
when tmp = 3 then region_name := 'Asia';
10
when tmp = 4 then region_name := 'Middle East and Africa';
11
else region_name := 'hello';
12 end
case;
13
dbms_output.put_line('region_id : '||region_name);
14* end;
SQL> /
region_id : Asia
PL/SQL procedure
successfully completed.
SQL>