php sql语句嵌套,PL/SQL嵌套IF-THEN-ELSE语句

在PL/SQL编程中嵌套IF-ELSE语句总是合法的,也就是说可以在一个IF或ELSE IF语句中使用另一个IF或ELSE IF语句。

语法

PL/SQL中嵌套IF-ELSE语句的语法是 -

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;

实例

请参考以下示例代码 -

SET SERVEROUTPUT ON SIZE 1000000;

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提示符下执行时,它会产生以下结果 -

ee849a5fe81930c9f3c766f9e6b49965.png

¥ 我要打赏

纠错/补充

收藏

加QQ群啦,易百教程官方技术学习群

注意:建议每个人选自己的技术方向加群,同一个QQ最多限加 3 个群。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值