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 when改寫SQLOracleSQL
- Oracle vs PostgreSQL Develop(30) - Index&Case whenOracleSQLdevIndex
- Oracle 11g新特新--SQL Test Case BuilderOracleSQLUI
- Oracle 條件索引 case when 報錯解決方案Oracle索引
- oracle 19c sec_case_sensitive_logon引數問題OracleGo
- 【每日一包0013】to-capital-case,to-constant-case,to-dot-caseAPI
- Oracle group by與case when統一單位後統計數量Oracle
- Java switch caseJava
- Java Case InterviewJavaView
- case when 語句
- SQL CASE 表示式SQL
- lower_case_table_names
- switch_case練習
- mysql中case when的使用MySql
- sql case when, Exist ,group by ,聚合SQL
- 2.3.1.1.2 Application Container Use Case: SaaSAPPAI
- while迴圈 case迴圈While
- SQL Server CASE WHEN ... THEN ... ELSE ... ENDSQLServer
- SQLServer使用case when中的order bySQLServer
- JAVA基礎--Switch case語句Java
- [network][easy case]troubleshoting the connection to a remote serverREMServer
- Golang switch case 的使用注意點Golang
- java中的switch case語句Java
- Judging only on arm talent it is difficult to make a case
- CSS Case Insensitive Attribute Selector All In OneCSS
- use-case-airflow-llm-rag-financeAINaN
- 條件判斷語句 if case
- [case39]聊聊jdk httpclient的executorJDKHTTPclient
- 瞭解GaussDB SQL中CASE表示式SQL
- UML建模——用例圖(Use Case Diagram)
- 2.3.1.1.3 Application Containers Use Case: Logical Data WarehouseAPPAI
- go select case的一個小坑Go
- @Transactional 四種不生效的 case 分析
- [ Shell ] 兩個 case 實現 GetOptions 效果
- printf格式控制、switch-case語句
- Python在類中實現swith case功能Python
- 使用 Drools 和 JPA & Drools show case in docker hubDocker
- [case37]聊聊lettuce的shareNativeConnection引數
- 神奇的 SQL 之 CASE表示式,妙用多多 !SQL