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

comparing null value in plpgsql.

From: Bhuvan A <bhuvansql(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: comparing null value in plpgsql.
Date: 2002-03-11 05:14:28
Message-ID: Pine.LNX.4.20.0203111029130.23906-100000@Larry (view raw or flat)
Thread:
Lists: pgsql-bugs
hi,

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. 

to overcome this, i am practicing..

  create function ftest()
  returns opaque as 'declare

  begin

    if  new.comp_code is not null and
        old.comp_code is null then
        ...
    else if new.comp_code != old.comp_code then
      ...
    end if;
    end if;

    return new;
  end;'
  language 'plpgsql';

is it really a bug or i am wrong? let me know. if its a bug, when can we
expect the fix?

kindly apologize if it has been already discussed.

Regards,
Bhuvaneswaran.



Responses

pgsql-bugs by date

Next:From: Stephan SzaboDate: 2002-03-11 06:10:45
Subject: Re: comparing null value in plpgsql.
Previous:From: Peter T MountDate: 2002-03-09 11:50:08
Subject: Fwd: Bug in getTimestamp() of PostgreSQL JDBC driver?

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