PL/SQL中的循环(很low,以后慢慢完善)
2017-05-02 14:43
253 查看
declare
v_nu Integer:=1;
begin
if v_nu=1 then
dbms_output.put_line('星期一');
elsif v_nu=2 then
dbms_output.put_line('星期二');
else
dbms_output.put_line('其它');
end if;
end;
/*if判断(根据系统时间输出星期几)*/
declare
v_days Integer:=to_number(to_char(sysdate,'D'));
begin
if v_days=1 then
dbms_output.put_line('星期天');
elsif v_days=2 then
dbms_output.put_line('星期一');
elsif v_days=3 then
dbms_output.put_line('星期二');
elsif v_days=4 then
dbms_output.put_line('星期三');
elsif v_days=5 then
dbms_output.put_line('星期四');
elsif v_days=6 then
dbms_output.put_line('星期五');
else
dbms_output.put_line('星期六');
end if;
end;
/*loop循环*/
declare
v_num2 Integer:=0;
begin loop
dbms_output.put_line('这是第'||v_num2||'次循环');
v_num2:=v_num2+1;
if v_num2>10 then
exit;
end if;
end loop;
dbms_output.put_line('循环结束');
end;
/*for循环*/
declare
begin
for v_num in 0..10 loop
dbms_output.put_line('这是第'||v_num||'次循环');
end loop;
end;
/*while循环*/
declare
v_num Integer:=0;
begin
while v_num<10 loop
dbms_output.put_line('这是第'||'次循环');
v_num:=v_num+1;
end loop;
end;
v_nu Integer:=1;
begin
if v_nu=1 then
dbms_output.put_line('星期一');
elsif v_nu=2 then
dbms_output.put_line('星期二');
else
dbms_output.put_line('其它');
end if;
end;
/*if判断(根据系统时间输出星期几)*/
declare
v_days Integer:=to_number(to_char(sysdate,'D'));
begin
if v_days=1 then
dbms_output.put_line('星期天');
elsif v_days=2 then
dbms_output.put_line('星期一');
elsif v_days=3 then
dbms_output.put_line('星期二');
elsif v_days=4 then
dbms_output.put_line('星期三');
elsif v_days=5 then
dbms_output.put_line('星期四');
elsif v_days=6 then
dbms_output.put_line('星期五');
else
dbms_output.put_line('星期六');
end if;
end;
/*loop循环*/
declare
v_num2 Integer:=0;
begin loop
dbms_output.put_line('这是第'||v_num2||'次循环');
v_num2:=v_num2+1;
if v_num2>10 then
exit;
end if;
end loop;
dbms_output.put_line('循环结束');
end;
/*for循环*/
declare
begin
for v_num in 0..10 loop
dbms_output.put_line('这是第'||v_num||'次循环');
end loop;
end;
/*while循环*/
declare
v_num Integer:=0;
begin
while v_num<10 loop
dbms_output.put_line('这是第'||'次循环');
v_num:=v_num+1;
end loop;
end;
相关文章推荐
- pl/sql 中for和while循环([PL/SQL] 用For Loop 替代Cursor)
- 《oracle pl/sql programming》 第四章 条件与顺序控制 第五章 迭代与循环
- PL/SQL中使用EXISTS:使用LOOP循环替代或者SELECT实现类似的功能:
- PL/SQL中操作符、条件和循环控制
- PL/SQL循环
- pl/sql编程之循环操作
- PL/SQL的循环控制
- pl/sql之控制结构(分支,循环,控制)
- PL/SQL条件分支以及循环结构
- pl/sql 之三大循环的完全学习指南
- PL_SQL 的 循环语句FOR 循环测试
- PL/SQL学习笔记-循环控制与顺序控制
- Oracle中PL/SQL的循环语句
- Oracle PL/SQL 程序设计读书笔记 - 第5章 用循环进行迭代处理
- 微软TTS语音引擎程序支持中英混读,其中需要有语音引擎----暂时写这些以后再慢慢完善 如果哪位朋友需要请联系我我把源代码奉上
- Oracle PL/SQL 常量/变量/标量 (待完善)
- 慢慢总结PHP面试题,在不断的完善中,希望对以后应聘有好处,答案我都会测试过的
- pl/sql用for in和for select into循环遍历表
- 二十五、oracle pl/sql进阶--控制结构(分支,循环,控制)
- PL/SQL的定义(五)循环控制