Tuesday, July 8, 2008

[GENERAL] plpgsql - or operator?

If I have an expression (a or b)a where a=TRUE and b=FALSE, why is b evaluated?  Any true operand before an or operator means the entire expression is true …

 

---------------------------- EXAMPLE

create or replace function pinsusers() returns trigger as

$$

declare msg varchar;

begin

            --THROWS EXCEPTION when ((TG_OP = 'INSERT') is TRUE “record old is not assigned yet”

            msg = ((TG_OP = 'INSERT') or (new.password<>old.password));

            raise exception '%',msg;

            return new;

end

$$ language plpgsql;

------------------------------------------------------

 

TY J

No comments: