Search Postgresql Archives

Re: Rules and conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux