Re: Rules and conditions
От | Guillaume Lelarge |
---|---|
Тема | Re: Rules and conditions |
Дата | |
Msg-id | 200912091321.22168.guillaume@lelarge.info обсуждение исходный текст |
Ответ на | Re: Rules and conditions (George Silva <georger.silva@gmail.com>) |
Список | pgsql-general |
Le mercredi 9 décembre 2009 à 12:38:33, George Silva a écrit : > Hello guys, > > Still having some trouble with this. > > I'm trying to use a case when, but postgres is still giving me syntax > error. > > CREATE OR REPLACE RULE instead_update AS ON UPDATE TO foo > DO INSTEAD > ( > CASE SELECT exists(SELECT 1 FROM versioning.foo_version_1 WHERE > OLD.oid = NEW.oid) as a WHEN a=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; > WHEN a=false THEN > INSERT INTO versioning.foo_version_1(NEW.*,'UPDATE'); > END > ); > > Any thoughts? > You can't use the CASE structure this way. You really need to use a stored function. -- Guillaume. http://www.postgresqlfr.org http://dalibo.com
В списке pgsql-general по дате отправления: