Oracle PL/SQL系列教程之PL/SQL嵌套IF-THEN-ELSE语句行业动态

首页 行业动态 Oracle PL/SQL系列教程之PL/SQL嵌套IF-THEN-ELSE语句

Oracle PL/SQL系列教程之PL/SQL嵌套IF-THEN-ELSE语句

2018-07-19 21:27:20


详情:

PL/SQL编程嵌套if-else语句,可以使用一个IF或ELSE IF语句中的另一个IF或ELSE IF语句。

语法:

IF( boolean_expression 1)THEN
-- executes when the boolean expression 1 is true 
IF(boolean_expression 2) THEN
-- executes when the boolean expression 2 is true 
sequence-of-statements;
 END IF;ELSE
 -- executes when the boolean expression 1 is not true
else-statements;END IF;

示例:

DECLARE
 a number(3) := 100;
 b number(3) := 200;BEGIN
 -- check the boolean condition 
 IF( a = 100 ) THEN
 -- if condition is true then check the following 
IF( b = 200 ) THEN
-- if condition is true then print the following 
 dbms_output.put_line('Value of a is 100 and b is 200' );
END IF;
 END IF;
 dbms_output.put_line('Exact value of a is : ' || a );
 dbms_output.put_line('Exact value of b is : ' || b );END;/

当上述代码在SQL提示符执行时,它产生了以下结果:

Value of a is 100 and b is 200
Exact value of a is : 100
Exact value of b is : 200

PL/SQL procedure successfully completed.


相关 教程

12c OCM升级培训

12c OCM升级培训

11g OCM于2019年12月31日退役,12c OCM成为目前最新、最高版本的Oracle DBA认证。含金量无出其右。}

11g OCP培训

11g OCP培训

11g OCP培训}

OCJP认证培训

OCJP认证培训

OCJP认证培训}

网上报名 免费试学+报名即可领取免费资料

收缩

QQ在线客服

  • 刘老师
  • 在线咨询
  • 麦老师
  • 在线咨询
  • 黄老师
  • 在线咨询
在线免费试课
获取免费课程视频资料