时间:2021-07-21人气:-
本文我们主要介绍了Oracle数据库中各种控制语句的使用,包括逻辑控制语句、Case when的使用、While的使用以及For的使用等,希望本次的介绍能够对您有所收获!
Oracle数据库各类控制语句的使用是本文我们主要要介绍的内容,包括一些逻辑控制语句、Case when的使用、While的使用以及For的使用等等,接下来我们就开始一一介绍这部分内容,希望能够对您有所帮助。
Oracle 中逻辑控制语句
- Ifelsifelseendifsetserverouton;
- declareper_dep_countnumber;begin
- selectcount(*)intoper_dep_countfromemp;ifper_dep_count>0then
- dbms_output.put_line('BigThan0');elsifper_dep_count>5then<spanstyle="font-size:24px;color:#ff0000;"><strong>--elsifnotelseif!!!!
- </strong></span>dbms_output.put_line('BigThan5');else
- dbms_output.put_line('En?');endif;
- end;
Case when 的使用的两种方式 :
第一种使用方式
- declareper_dep_countnumber;begin
- selectcount(*)intoper_dep_countfromemp;caseper_dep_count
- when1thendbms_output.put_line('1');
- when2thendbms_output.put_line('2');
- elsedbms_output.put_line('else');
- endcase;end;
第二种使用方式
- declareper_dep_countnumber;begin
- selectcount(*)intoper_dep_countfromemp;case
- whenper_dep_count=1thendbms_output.put_line('1');
- whenper_dep_count=2thendbms_output.put_line('2');
- elsedbms_output.put_line('else');
- endcase;end;
While 的使用
- declarev_idnumber:=0;begin
- whilev_id<5loopv_idv_id:=v_id+1;
- dbms_output.put_line(v_id);endloop;
- end;
For的使用
- declarev_idnumber:=0;begin
- forv_idin1..5loopdbms_output.put_line(v_id);
- endloop;end;
关于Oracle数据库各类控制语句的使用就介绍到这里了,希望本次的介绍能够对您有所收获!