I'm trying to compare the fields of two loop record variables. The loops
are nested, the compare is done inside the inner one. If given this:
raise notice ''sloop.serialnumber=%, rloop.serialnumber=%'', sloop.serialnumber, rloop.serialnumber;
if sloop.serialnumber=rloop.serialnumber then raise notice '' SN match''; else raise notice '' SN mis-match''; end
if;
the output is
NOTICE: sloop.serialnumber=<NULL>, rloop.serialnumber=<NULL> NOTICE: SN mis-match
However, if you change the comparison to
if sloop.serialnumber=rloop.serialnumber or (sloop.serialnumber=null and rloop.serialnumber=null) then raise
notice'' SN match''; else raise notice '' SN mis-match''; end if;
everything is fine.
Question: does null=null evaluate to true, false, or null? If in psql you
do SELECT null=null; it returns true. Am I missing something? Attached
is the full trigger code..
Thanks,
-Cedar