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

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to