jeudi 3 juin 2021

IF WITH ORs conditions not runnng as expected PL/SQL

Hello I have this easy sample code not running as I expect in PL/SQL:

declare 

A NUMBER := NULL;
B NUMBER := NULL;
C NUMBER := NULL;
D NUMBER := NULL;
E NUMBER := 7;

BEGIN

IF A != NULL OR B != NULL OR C != NULL OR D != NULL OR E != NULL THEN

DBMS_OUTPUT.PUT_LINE('IF');

ELSE 

DBMS_OUTPUT.PUT_LINE('ELSE');

END IF;

END;

So as far as I know, when multiple ORs go as condition as long as one of them is true, the condition becomes true for all of them too. So in thos case E is 7, so E is != to 7, so in my mind it should enter the IF, but in the output "ELSE" comes.

Aucun commentaire:

Enregistrer un commentaire