Trigger to change different row in same table

Поиск
Список
Период
Сортировка
Искать
От
PostgreSQL Admin
Тема
Trigger to change different row in same table
Дата
Msg-id
46DD7634.4090408@productivitymedia.com
Ответ на
Список
Дерево обсуждения
Difference between "foo is false" and "foo=false"? Partial index on boolean. Bryce Nesbitt <bryce1@obviously.com>
Re: Difference between "foo is false" and "foo=false"? Partial index on boolean. Tom Lane <tgl@sss.pgh.pa.us>
Re: Difference between "foo is false" and "foo=false"? Partial index on boolean. Bryce Nesbitt <bryce1@obviously.com>
Re: Difference between "foo is false" and "foo=false"? Partial index on boolean. Richard Huxton <dev@archonet.com>
Partial index on boolean - Sometimes fails to index scan Bryce Nesbitt <bryce1@obviously.com>
Re: Partial index on boolean - Sometimes fails to index scan Bryce Nesbitt <bryce1@obviously.com>
Trigger to change different row in same table PostgreSQL Admin <postgres@productivitymedia.com>
I want to write a trigger that updates a different row on the same
table. It's pretty basic: before the any row  in his table updated I
want to set a only row that has the value true to false.  I keep getting
this error:

SQL statement "update theirry.articles set master_featured = false where
master_featured = true"
PL/pgSQL function "master_featured_maintenance" line 4 at SQL statement

My basic trigger:

CREATE OR REPLACE FUNCTION theirry.master_featured_maintenance()
RETURNS TRIGGER AS
$master_featured_maintenance$   DECLARE       master_feature boolean;   BEGIN           update theirry.articles           set master_featured = false           where master_featured = true;   END;
$master_featured_maintenance$
LANGUAGE plpgsql;

CREATE TRIGGER master_featured_maintenance
BEFORE INSERT OR UPDATE ON theirry.articles   FOR EACH ROW EXECUTE PROCEDURE  theirry.master_featured_maintenance();


Thanks in advance,
J

В списке pgsql-sql по дате отправления
От: Tom Lane
Дата:
От: PostgreSQL Admin
Дата:
FAQ