Received: from presence1.observatoiredesmarques.fr (presence1.observatoiredesmarques.fr [212.73.199.68]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fBLAiDm70629; Fri, 21 Dec 2001 05:44:13 -0500 (EST) (envelope-from richard@presenceweb.com) Received: from presenceweb.com (gatei.observatoiredesmarques.fr [80.8.24.69]) by presence1.observatoiredesmarques.fr (8.9.3/8.9.3/Maild V.4-1) with ESMTP id LAA20812; Fri, 21 Dec 2001 11:46:02 +0100 X-Authentication-Warning: presence1.observatoiredesmarques.fr: Host gatei.observatoiredesmarques.fr [80.8.24.69] claimed to be presenceweb.com Message-ID: <3C230710.BD7AD6A8@presenceweb.com> Date: Fri, 21 Dec 2001 10:55:28 +0100 From: Richard NAGY Organization: Presenceweb / Nameshield X-Mailer: Mozilla 4.72 [fr] (X11; U; Linux 2.2.14-6.1.1smp i686) X-Accept-Language: fr, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org, pgsql-general@postgresql.org Subject: strange problem with plpgsql Content-Type: multipart/alternative; boundary="------------9674C8DD408802222E839C3E" X-Archive-Number: 200112/152 X-Sequence-Number: 2875 --------------9674C8DD408802222E839C3E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------9674C8DD408802222E839C3E Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit 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
  --------------9674C8DD408802222E839C3E--