Rules and conditions

From: George Silva <georger(dot)silva(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Rules and conditions
Date: 2009-12-09 00:52:03
Message-ID: 9aa147370912081652y7e58058fsc37a12838c660ae5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-09 01:03:21 Re: Excessive (and slow) fsync() within single transaction
Previous Message Stephen Tyler 2009-12-09 00:28:52 Excessive (and slow) fsync() within single transaction