The ELSE clause in PL/SQL specifies the alternative execution path when the condition is false in the IF-THEN-ELSE statement. The syntax is: IF condition THEN code block 1 ELSE code block 2 END IF. Its uses include specifying operations when a condition is false, handling different results, and handling special cases.
Usage of ELSE clause in PL/SQL
The ELSE clause is used in PL/SQL control statements (such as IF-THEN-ELSE) specifies an alternative execution path when the condition is false.
Syntax
<code>IF condition THEN -- 代码块 1 -- 如果条件为真,则执行 ELSE -- 代码块 2 -- 如果条件为假,则执行 END IF;</code>
Usage
The ELSE clause is used in the following situations:
Example
<code>-- 检查一个数字是否是偶数 DECLARE number NUMBER := 10; BEGIN IF number MOD 2 = 0 THEN DBMS_OUTPUT.PUT_LINE('该数字是偶数。'); ELSE DBMS_OUTPUT.PUT_LINE('该数字是奇数。'); END IF; END;</code>
Output:
<code>该数字是偶数。</code>
Note:
The above is the detailed content of Usage of else in plsql. For more information, please follow other related articles on the PHP Chinese website!