2、if、case when和循环语句
来源:互联网 发布:考研政治知乎 编辑:程序博客网 时间:2024/05/16 20:29
一、IF条件语句
set serverout on; (//此句作用:在控制台输出结果)
declare aj_count number;
begin
select count(*) into aj_count from tb_st_ajjbxx;
if aj_count> 10000 then
dbms_output.put_line('有' || aj_count || '个');
else
dbms_output.put_line('有' || aj_count || '个');
end if;
end;
二、CASE WHEN
set serverout on;
declare aj_count number;
begin
select count(*) into aj_count from tb_st_ajjbxx;
case when aj_count <10000 then dbms_output.put_line('有aa' || aj_count || '个');
when aj_count >=10000 then dbms_output.put_line('有bb' || aj_count || '个');
end case;
end;
三、循环语句
(1)无条件循环 loop
set serverout on;
declare g_id number:=1;
losal number;
hisal number;
begin
loop
if(g_id>3) then exit;
end if; (if then exit end if; 此处为loop循环必须的)
select username,password into losal,hisal from t_user where id=g_id;
dbms_output.put_line(g_id || '数值为' || losal || 'aaaa' || hisal);
g_id := g_id+1;
end loop;
end;
(2)while 循环
set serverout on;
declare g_id number:=1;
losal number;
hisal number;
begin
while g_id<3 loop
select username,password into losal,hisal from t_user where id=g_id;
dbms_output.put_line(g_id || '数值为' || losal || 'bbb' || hisal);
g_id := g_id+1;
end loop;
end;
(3)FOR 循环
set serverout on;
declare losal number;
hisal number;
begin
for g_id in 1..4 loop
select username,password into losal,hisal from t_user where id=g_id;
dbms_output.put_line(g_id || '数值为' || losal || 'bbb' || hisal);
end loop;
end;
- 2、if、case when和循环语句
- Mysql数据库if语句case when使用
- sql控制流程语句case when/if/ifnull/null if
- count, sum和 if,case when
- MySQL upate if和case when语法
- Sql语句:IF ELSE CASE WHEN WHILE CONTINUE BREAK
- if语句和循环语句
- shell中的if语句和case语句
- 条件控制:IF语句和CASE语句
- mysql的存储过程中的语句if case 循环语句
- case when 语句
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- mysql 语句case when
- sql语句 case when
- Linux下安装和配置SVN详细笔记
- 如何理解继承成员变量和方法的区别?
- dubbo扩展点
- Job Submission failed with exception 'java.lang.RuntimeException(ORC split generation failed with ex
- python爬取美女图片
- 2、if、case when和循环语句
- linux 进度条的脚本实现
- Lintcode 答案--自己做的,希望各位能补充更多的解法
- java如何制作验证码
- JavaScript中的数据类型
- JSBD
- BZOJ 1046-上升序列(DP)
- FLV-音频Tag
- Java多线程学习之生产者消费者问题(一)