Skip site navigation (1) Skip section navigation (2)

Re: comparing null value in plpgsql.

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Bhuvan A <bhuvansql(at)yahoo(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: comparing null value in plpgsql.
Date: 2002-03-11 08:15:34
Message-ID: 20020311001349.O39819-100000@megazone23.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, 11 Mar 2002, Bhuvan A wrote:

>
>
> On Mar 10, Stephan Szabo wrote:
>
> > On Mon, 11 Mar 2002, Bhuvan A wrote:
> >
> > > here i have a problem in comparing null values in plpgsql. this exist
> > > in 7.1.x and 7.2 as well.
> > >
> > > the condition <null value> != <valid value> fails in plpgsql.
> > > consider this function is triggered on every updation on a table.
> > >
> > >   create function ftest()
> > >   returns opaque as 'declare
> > >
> > >   begin
> > >
> > >     if new.comp_code != old.comp_code then
> > >       ...
> > >     end if;
> > >     return new;
> > >   end;'
> > >   language 'plpgsql';
> > >
> > > this condition fails if old.comp_code is null and new.comp_code has
> > > some value.
> >
> > <nullvalue> != <anything> is not true, it's unknown, so the if shouldn't
>
>   what do you mean by <nullvalue> != <anything>?

If you compare a NULL with anything you don't get a true value whether
you're comparing with =, !=, <, >, etc...  That's how it's defined to
behave.


In response to

pgsql-bugs by date

Next:From: Bhuvan ADate: 2002-03-11 10:26:50
Subject:
Previous:From: pgsql-bugsDate: 2002-03-11 08:09:54
Subject: Bug #612: PostgreSQL 7.2 does not build according to documentation under IRIX w/ MIPSpro

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group