首页 > 数据库技术 > 详细

数据库:循环语句--1:if then/elsif/end if.

时间:2017-07-18 19:36:54      阅读:513      评论:0      收藏:0      [点我收藏+]

if循环语句:

1:语法:

IF <布尔表达式> THEN

PL/SQL 和 SQL语句
END IF;
--或
IF <布尔表达式> THEN
PL/SQL 和 SQL语句
ELSIF
其它语句
END IF;

2:实例:

--查询姓名是Scott的工资。
declare
V_ename emp.ename%type :=‘SCOTT‘;
V_sal emp.sal%type;
V_comment varchar2(60);

begin
select sal into V_sal from emp where ename=V_ename;
if V_sal<1500 then
V_comment :=‘Fairly less‘;
elsif V_sal<3000 then
V_comment :=‘A little more‘;
else
V_comment :=‘Lots of money‘;
end if;
dbms_output.put_line(V_sal);
dbms_output.put_line(V_comment);
end;

数据库:循环语句--1:if then/elsif/end if.

原文:http://www.cnblogs.com/maqiang123/p/7202062.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!