plpgsql help - nested loops

From: Cedar Cox <cedarc(at)visionforisrael(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: plpgsql help - nested loops
Date: 2001-01-02 23:20:57
Message-ID: Pine.LNX.4.21.0101030107140.28193-200000@nanu.visionforisrael.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces


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

Attachment Content-Type Size
matchitems text/plain 3.9 KB

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 2001-01-03 00:14:48 Re: Asynchronous interface help?
Previous Message Ingo Luetkebohle 2001-01-02 22:53:21 Re: DBD::Pg