On Mon, Sep 28, 2009 at 10:12 AM, Jacques Caron wrote:
> Hi,
>
> You can use a trigger before insert and a pl/pgsql function that goes:
>
> BEGIN
> UPDATE table SET ... WHERE pk=NEW.pk
> IF FOUND THEN
> RETURN NULL;
> ELSE
> RETURN NEW;
> END IF;
> END;
>
> Jacques.
That seems about right.
Hi,
You can use a trigger before insert and a pl/pgsql function that goes:
BEGIN
UPDATE table SET ... WHERE pk=NEW.pk
IF FOUND THEN
RETURN NULL;
ELSE
RETURN NEW;
END IF;
END;
Jacques.
At 19:36 27/09/2009, Robert Haas wrote:
Sometimes when I've needed to do this I've written a PL/pgsql
--On 27. September 2009 14:36:45 -0400 Robert Haas
wrote:
On Sun, Sep 27, 2009 at 11:36 AM, Tom Lane wrote:
Robert Haas writes:
On Sat, Sep 26, 2009 at 12:35 PM, Tom Lane wrote:
Well, yeah. That's exactly how it's documented to work: an ON INSERT
rule is executed after the INSERT pro
On Sun, Sep 27, 2009 at 11:36 AM, Tom Lane wrote:
> Robert Haas writes:
>> On Sat, Sep 26, 2009 at 12:35 PM, Tom Lane wrote:
>>> Well, yeah. That's exactly how it's documented to work: an ON INSERT
>>> rule is executed after the INSERT proper.
>
>> I'm confused. DO INSTEAD doesn't mean DO INST
Robert Haas writes:
> On Sat, Sep 26, 2009 at 12:35 PM, Tom Lane wrote:
>> Well, yeah. That's exactly how it's documented to work: an ON INSERT
>> rule is executed after the INSERT proper.
> I'm confused. DO INSTEAD doesn't mean DO INSTEAD?
It does. What it doesn't mean is "IF ... THEN ... E
On Sat, Sep 26, 2009 at 12:35 PM, Tom Lane wrote:
> "Stefan" writes:
>> The problem is that if it is no record in the table, it seems that first the
>> INSERT command is issued and after that the UPDATE command is issued, too.
>
> Well, yeah. That's exactly how it's documented to work: an ON INS
"Stefan" writes:
> The problem is that if it is no record in the table, it seems that first the
> INSERT command is issued and after that the UPDATE command is issued, too.
Well, yeah. That's exactly how it's documented to work: an ON INSERT
rule is executed after the INSERT proper.
You could m