Search Postgresql Archives

BEFORE UPDATE trigger doesn't change column value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Sorry for this newbie-question, I am trying for quite some time now to get the following trigger-function to work properly:

CREATE OR REPLACE FUNCTION update_synced_column()
  RETURNS trigger AS
$BODY$
BEGIN
   IF NEW.synced IS NULL THEN
    NEW.synced :=  false;
   END IF;
   RETURN NEW;
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

The idea is basically to always update the "synced" column to false, unless a value has been provided manually in the UPDATE-clause.
Synced is defined as BOOLEAN DEFAULT FALSE;
I execute this function in a BEFORE UPDATE trigger FOR EACH ROW, however it doesn't seem to have any effect.

Any ideas what could be wrong here?

Thanks, Clemens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux