例子
DECLARE
a boolean := true;
b boolean := false;
BEGIN
IF (a AND b) THEN
dbms_output.put_line('Line 1 - Condition is true');
END IF;
IF (a OR b) THEN
dbms_output.put_line('Line 2 - Condition is true');
END IF;
IF (NOT a) THEN
dbms_output.put_line('Line 3 - a is not true');
ELSE
dbms_output.put_line('Line 3 - a is true');
END IF;
IF (NOT b) THEN
dbms_output.put_line('Line 4 - b is not true');
ELSE
dbms_output.put_line('Line 4 - b is true');
END IF;
END;
/
在 SQL 提示符下执行上述代码时,会产生以下结果 -
Line 2 - Condition is true
Line 3 - a is true
Line 4 - b is not true
PL/SQL procedure successfully completed.