Reputation: 4647
I want to use the IF-THEN-ELSE statement in PL/SQL.
I am writing a procedure and have two boolean
defined:
bool1 BOOLEAN;
bool2 BOOLEAN;
Now I am searching for something like
IF bool1 AND bool2 THEN
...
ELSE
...
END IF;
But I can't find anything similiar to that in the www.
I'm sure you can help me! ;)
Thanks for your help!
Upvotes: 3
Views: 19031
Reputation: 2051
Seems like you already got it. This code will work:
set serveroutput on;
DECLARE
bool1 BOOLEAN;
bool2 BOOLEAN;
BEGIN
bool1 := TRUE;
bool2 := FALSE;
IF bool1 AND bool2
THEN
DBMS_OUTPUT.put_line ('Both true');
ELSE
DBMS_OUTPUT.put_line ('Not both true');
END IF;
END;
Be aware though that in oracle booleans only exist in PL/SQL, not in SQL, so you can't have a column of the datatype boolean in the DB.
Upvotes: 4