跨零代码为大家提供高品质的解决方案,请大家多多来访,跨零不胜感激,在此谢过。
IF-THEN
语句的序列之后的ELSE
语句的可选序列,ELSE
语句块在IF
条件为FALSE
时执行。
语法
IF-THEN-ELSE
语句的语法是 –
IF condition THEN S1; ELSE S2; END IF;
其中,S1
和S2
是不同的语句序列。 在IF-THEN-ELSE
语句中,当测试条件为TRUE
时,执行语句S1
并跳过S2
; 当测试条件为FALSE
时,则跨过S1
并执行语句S2
中的语句块。 例如 –
IF color = red THEN dbms_output.put_line('You have chosen a red car') ELSE dbms_output.put_line('Please choose a color for your car'); END IF;
如果布尔表达式条件求值为真,则将执行if-then
代码块,否则将执行else
代码块。
流程图 –
示例
请看下面一个例子,演示如何使用 –
SET SERVEROUTPUT ON SIZE 1000000; DECLARE a number(3) := 100; BEGIN -- check the boolean condition using if statement IF( a < 20 ) THEN -- if condition is true then print the following dbms_output.put_line('a is less than 20 ' ); ELSE dbms_output.put_line('a is not less than 20 ' ); END IF; dbms_output.put_line('value of a is : ' || a); END; /
当上述代码在SQL提示符下执行时,它会产生以下结果 –
从零到一,创造未来!跨零综合IT问题解决服务站,欢迎你的到来。Oracle数据库教程 plsql数据库/a> 只为你绽放。
本文固定链接: http://kua0.com/2019/05/07/orientdb数据库-pl-sql-if-then-else语句/