国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

詳解Oracle數據庫各類控制語句的使用

2024-08-29 13:58:27
字體:
來源:轉載
供稿:網友

本文我們主要介紹了Oracle數據庫中各種控制語句的使用,包括邏輯控制語句、Case when的使用、While的使用以及For的使用等,希望本次的介紹能夠對您有所收獲!

Oracle數據庫各類控制語句的使用是本文我們主要要介紹的內容,包括一些邏輯控制語句、Case when的使用、While的使用以及For的使用等等,接下來我們就開始一一介紹這部分內容,希望能夠對您有所幫助。

Oracle 中邏輯控制語句

 

 
  1. If elsif else end if  
  2. set serverout on;  
  3. declare per_dep_count number;  
  4. begin 
  5. select count(*) into per_dep_count from emp;  
  6. if per_dep_count>0 then 
  7. dbms_output.put_line('Big Than 0');  
  8. elsif per_dep_count>5 then <span style="font-size:24px;color:#ff0000;"><strong>--elsif not elseif!!!!  
  9. </strong></span> dbms_output.put_line('Big Than 5');  
  10. else 
  11. dbms_output.put_line('En?');  
  12. end if;  
  13. end; 

Case when 的使用的兩種方式 :

第一種使用方式

 

 
  1. declare per_dep_count number;  
  2. begin 
  3. select count(*) into per_dep_count from emp;  
  4. case per_dep_count  
  5. when 1 then 
  6. dbms_output.put_line('1');  
  7. when 2 then 
  8. dbms_output.put_line('2');  
  9. else 
  10. dbms_output.put_line('else');  
  11. end case;  
  12. end;  

第二種使用方式

 

 
  1. declare per_dep_count number;  
  2. begin 
  3. select count(*) into per_dep_count from emp;  
  4. case 
  5. when per_dep_count=1 then 
  6. dbms_output.put_line('1');  
  7. when per_dep_count=2 then 
  8. dbms_output.put_line('2');  
  9. else 
  10. dbms_output.put_line('else');  
  11. end case;  
  12. end;  

While 的使用

 

 
  1. declare v_id number:=0;  
  2. begin 
  3. while v_id<5 loop  
  4. v_idv_id:=v_id+1;  
  5. dbms_output.put_line(v_id);  
  6. end loop;  
  7. end;  

For的使用

 

 
  1. declare v_id number:=0;  
  2. begin 
  3. for v_id in 1..5 loop  
  4. dbms_output.put_line(v_id);  
  5. end loop;  
  6. end;  

關于Oracle數據庫各類控制語句的使用就介紹到這里了,希望本次的介紹能夠對您有所收獲!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扬中市| 溆浦县| 贞丰县| 淮南市| 临朐县| 广水市| 交城县| 浠水县| 中西区| 获嘉县| 合阳县| 石柱| 嵩明县| 沙坪坝区| 马关县| 那坡县| 辉南县| 龙陵县| 睢宁县| 尉犁县| 兰溪市| 务川| 交口县| 娱乐| 肥乡县| 淮安市| 延安市| 徐水县| 大兴区| 师宗县| 丰顺县| 嵊州市| 广宗县| 柞水县| 西华县| 自治县| 高安市| 宁化县| 米易县| 易门县| 剑河县|