pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trigger to change different row in same table
2+ messages / 1 participants
[nested] [flat]

* Trigger to change different row in same table
@ 2007-09-04 15:13  PostgreSQL Admin <postgres@productivitymedia.com>
  0 siblings, 0 replies; 2+ messages in thread

From: PostgreSQL Admin @ 2007-09-04 15:13 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Trigger to change different row in same table
@ 2007-09-04 15:27  PostgreSQL Admin <postgres@productivitymedia.com>
  0 siblings, 0 replies; 2+ messages in thread

From: PostgreSQL Admin @ 2007-09-04 15:27 UTC (permalink / raw)
  To: chester c young <chestercyoung@yahoo.com>; pgsql-sql

chester c young wrote:
> how are you preventing recursion?
>
>   

That could be the problem, suggestions?



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-09-04 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-09-04 15:13 Trigger to change different row in same table PostgreSQL Admin <postgres@productivitymedia.com>
2007-09-04 15:27 Re: Trigger to change different row in same table PostgreSQL Admin <postgres@productivitymedia.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox