> > How can I write a few lines of PL/pgSQL which do not involve creating
> > a function? I can find no examples of this in the docs, but say I
> > would like to do something like
> >
> > BEGIN
> > IF EXISTS (SELECT * FROM foo WHERE idx = 27)
> > THEN
> > UPDATE foo SET var='some value' WHERE idx=27;
> > ELSE
> > INSERT INTO foo (idx, var) VALUES (27, 'some value');
> > END IF
> > END;
Interesting. I see you are trying to simulate MySQL's 'REPLACE INTO'
syntax.
On an aside, I was recently asked to convert this MySQL code to PGSQL code
for the GeekLog project. I gave up:
REPLACE INTO $table ($fields) SELECT $values FROM $tablefrom;
Evil!
Chris