Re: Modified FIFO queue and insert rule - Mailing list pgsql-general

From Leif B. Kristensen
Subject Re: Modified FIFO queue and insert rule
Date
Msg-id 200708091814.43789.leif@solumslekt.org
Whole thread Raw
In response to Re: Modified FIFO queue and insert rule  (Alban Hertroys <alban@magproductions.nl>)
Responses Re: Modified FIFO queue and insert rule  (Decibel! <decibel@decibel.org>)
List pgsql-general
On Wednesday 8. August 2007 15:12, Alban Hertroys wrote:
>You should probably use a trigger (a before one maybe) instead of a
> rule.

I tried that too, but I'm still quite shaky on how to write triggers,
and the same thing happened there: the inserted record was immediately
deleted. I solved the problem temporarily with two lines in PHP:

function set_last_selected_place($place) {
    pg_query("DELETE FROM recent_places WHERE place_fk = $place");
    pg_query("INSERT INTO recent_places (place_fk) VALUES ($place)");
}

As my application is single-user, and everything is already wrapped up
in a transaction anyway, there's no real problem with this. But I'd
still like to understand how to do it 'properly' inside the DB.
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE
My Jazz Jukebox: http://www.last.fm/user/leifbk/

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [JDBC] Restore database from zipped textfile (.sql) created by pg_dumpall
Next
From: "Woody Woodring"
Date:
Subject: Bytea question with \208