Trigger to change different row in same table

Поиск
Список
Период
Сортировка
От PostgreSQL Admin
Тема Trigger to change different row in same table
Дата
Msg-id 46DD7634.4090408@productivitymedia.com
обсуждение исходный текст
Ответ на Re: Partial index on boolean - Sometimes fails to index scan  (Bryce Nesbitt <bryce1@obviously.com>)
Список pgsql-sql
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
Дата:
Сообщение: Re: Cast on character columns in views
Следующее
От: PostgreSQL Admin
Дата:
Сообщение: Re: Trigger to change different row in same table