Search This Blog

Tuesday, July 31, 2012

Null Within expression


Null within an expression evaluates the complete expression to NULL. ( even on conditional statements )


Example:

declare
   flag1 boolean;
   flag2 boolean;
 begin
  
   flag1 := (null > trunc(sysdate));  --Flag1 evaluates to Null , not to False
  
   flag2 := true;
  
   if  flag1 and flag2 then
     raise_application_error(-20001,'true');
   elsif not flag1 then
     raise_application_error(-20001,'flag1: false , flag2 may be true or false');
   elsif not flag2 then
     raise_application_error(-20001,'flag2: false & flag1 : True');
   else
     raise_application_error(-20001,'case trapped');
   end if;
end;

No comments:

Post a Comment