Rules and conditions - Mailing list pgsql-general

From George Silva
Subject Rules and conditions
Date
Msg-id 9aa147370912081652y7e58058fsc37a12838c660ae5@mail.gmail.com
Whole thread Raw
Responses Re: Rules and conditions  (Guillaume Lelarge <guillaume@lelarge.info>)
List pgsql-general
Hello guys,

I can't seem to understand why a simples if is not working on the
creation of rules.

I tried both ways (am i missing something?):

Take a look:

CREATE OR REPLACE RULE instead_update AS ON UPDATE TO foo
DO INSTEAD
(
    IF exists(SELECT 1 FROM versioning.foo_version_1 WHERE oid = new.oid)
= TRUE THEN
        UPDATE versioning.foo_version_1 SET
            oid = new.oid,
            att1 = new.att1,
            att2 = new.att2,
            the_geom = new.the_geom,
            status = 'UPDATE'
        WHERE oid = new.oid;
    ELSE
        INSERT INTO versioning.foo_version_1 VALUES (NEW.*,'UPDATE');
    END IF;
)

Any toughts?

Thanks
--
George R. C. Silva

Desenvolvimento em GIS
www.sextantegeo2.blogspot.com

pgsql-general by date:

Previous
From: jackassplus
Date:
Subject: Re: Counts and percentages and such
Next
From: Tom Lane
Date:
Subject: Re: Excessive (and slow) fsync() within single transaction