pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard NAGY <richard@presenceweb.com>
To: pgsql-admin@postgresql.org
To: pgsql-general@postgresql.org
Subject: strange problem with plpgsql
Date: Fri, 21 Dec 2001 10:55:28 +0100
Message-ID: <3C230710.BD7AD6A8@presenceweb.com> (raw)

hello,

I have a strange problem with a plpgsql function. Here is the code :

      create function tg_survey_au() returns opaque as '
      begin
        if new.dateexpire != old.dateexpire or new.email != old.email
then
           insert into survey_log values (
              current_timestamp,
              ''update'',
              new.idxsurvey,
              new.dateexpire,
              new.email
           );
         end if;
       return new;
      end;
      ' language 'plpgsql';

      create trigger tg_survey_au after update on survey for each row
execute procedure tg_survey_au();


The problem is about the 'or' in the if statement. I have tested the if
statement with just one condition. One with dateexpire and one with
email. It works very well. Then I have joined the two conditions in the
if statement with an 'or' like here in the code. Then, I have an insert
in survey_log just when the email change, not if the dateexpire change!
It seems that the 'or' does not work.

Any idea ?

Note : The tests have been tested on a postgresql version 7.0.2 on a
RedHat Linux 6.2 machine.

--
Richard NAGY
Presenceweb / Nameshield

Message-ID: <3C230710.BD7AD6A8@presenceweb.com>
Permalink:  ../3C230710.BD7AD6A8@presenceweb.com/
Also on:    postgresql.org/message-id/3C230710.BD7AD6A8@presenceweb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: richard@presenceweb.com, pgsql-general@postgresql.org
  Subject: Re: strange problem with plpgsql
  In-Reply-To: <3C230710.BD7AD6A8@presenceweb.com>
  References: <3C230710.BD7AD6A8@presenceweb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox