Received: from mail.astrofoto.org (dsl092-102-177.nyc2.dsl.speakeasy.net [66.92.102.177]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fAFGn7m21054; Thu, 15 Nov 2001 11:49:07 -0500 (EST) (envelope-from roland@astrofoto.org) Received: (from roland@localhost) by mail.astrofoto.org (8.11.6/8.11.6) id fAFGnC415532; Thu, 15 Nov 2001 11:49:12 -0500 To: pgsql-sql@postgresql.org, pgsql-docs@postgresql.org Subject: PL/pgSQL examples NOT involving functions From: Roland Roberts Date: 15 Nov 2001 11:49:12 -0500 Message-ID: Lines: 19 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.105 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200111/51 X-Sequence-Number: 1124 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; roland -- PGP Key ID: 66 BC 3B CD Roland B. Roberts, PhD RL Enterprises roland@rlenter.com 76-15 113th Street, Apt 3B roland@astrofoto.org Forest Hills, NY 11375