oracle case
/******************************/
case語句,求助高手
幾個when分支執行相同操作,怎麼合併到一塊
比如:
case selector
when a then A;
when b then A;
when c then B;
when d then B;
when e then C
end case;
/**************************************/
set serverout on
create table test (id varchar2(10));
insert into test values('1');
insert into test values('2');
insert into test values('3');
insert into test values('4');
insert into test values('5');
commit;
declare
cursor cur_test is select id from test;
begin
for row_cur in cur_test loop
case when row_cur.id='1' or row_cur.id='2' then
dbms_output.put_line('A');
when row_cur.id='3' or row_cur.id='4' then
dbms_output.put_line('B');
else
dbms_output.put_line('C');
end case;
end loop;
end;
/
declare
cursor cur_test is select id from test;
begin
for row_cur in cur_test loop
dbms_output.put_line(
case when row_cur.id='1' or row_cur.id='2' then
'A'
when row_cur.id='3' or row_cur.id='4' then
'B'
else
'C'
end);
end loop;
end;
/
declare
cursor cur_test is
select case
when id='1' or id='2' then 'A'
when id='3' or id='4' then 'B'
else 'C' end id
from test;
begin
for row_cur in cur_test loop
dbms_output.put_line(row_cur.id);
end loop;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18921899/viewspace-1016972/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle Case WhenOracle
- oracle plsql case when_end case小記OracleSQL
- oracle的case函式和case控制結構Oracle函式
- ORACLE CASE WHEN 及 SELECT CASE WHEN的用法Oracle
- Oracle的order by case whenOracle
- Oracle Case語句用法Oracle
- Oracle 中 case的用法Oracle
- Oracle case when改寫SQLOracleSQL
- oracle case處理案例(一)Oracle
- ORACLE多欄位CASE WHENOracle
- 案例:oracle中case when的用法Oracle
- Oracle vs PostgreSQL Develop(30) - Index&Case whenOracleSQLdevIndex
- oracle面試題[關於case when的用法]Oracle面試題
- ORACLE SQL開發where子句之case-whenOracleSQL
- SQL Server、Oracle中CASE 與COUNT合用計數SQLServerOracle
- Oracle 條件索引 case when 報錯解決方案Oracle索引
- Oracle 11g新特新--SQL Test Case BuilderOracleSQLUI
- sqlserver與oracle case when else ,isnull語法差別SQLServerOracleNull
- sql case語法和plsql case語法!SQL
- 【每日一包0013】to-capital-case,to-constant-case,to-dot-caseAPI
- Oracle Decode()函式和CASE語句的比較Oracle函式
- Oracle IZ0-053 Q24(SQL Test Case Builder)OracleSQLUI
- Java Case InterviewJavaView
- Java switch caseJava
- case class inheritance
- SQL Case WhenSQL
- 【SQL】小CASESQL
- plsql_case when_end case學習小例SQL
- SQL CASE 表示式SQL
- mysql case when then 使用MySql
- Index rebuild --case 1IndexRebuild
- Oracle group by與case when統一單位後統計數量Oracle
- oracle 19c sec_case_sensitive_logon引數問題OracleGo
- switch case 的 expected expressionExpress
- Go語言 - switch/caseGo
- Clear Case usage tips
- 代替DECODE的CASE
- Case when 支援變數變數