详解Oracle数据库各类控制语句的使用
Oracle数据库各类控制语句的使用是本文我们主要要介绍的内容,包括一些逻辑控制语句、Casewhen的使用、While的使用以及For的使用等等,接下来我们就开始一一介绍这部分内容,希望能够对您有所帮助。
Oracle中逻辑控制语句
Ifelsifelseendif
setserverouton;
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;
Casewhen的使用的两种方式 :
第一种使用方式
declareper_dep_countnumber;
begin
selectcount(*)intoper_dep_countfromemp;
caseper_dep_count
when1then
dbms_output.put_line('1');
when2then
dbms_output.put_line('2');
else
dbms_output.put_line('else');
endcase;
end;
第二种使用方式
declareper_dep_countnumber;
begin
selectcount(*)intoper_dep_countfromemp;
case
whenper_dep_count=1then
dbms_output.put_line('1');
whenper_dep_count=2then
dbms_output.put_line('2');
else
dbms_output.put_line('else');
endcase;
end;
While的使用
declarev_idnumber:=0; begin whilev_id<5loop v_idv_id:=v_id+1; dbms_output.put_line(v_id); endloop; end;
For的使用
declarev_idnumber:=0; begin forv_idin1..5loop dbms_output.put_line(v_id); endloop; end;
关于Oracle数据库各类控制语句的使用就介绍到这里了,希望本次的介绍能够对您有所收获!
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短