pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roland Roberts <roland@astrofoto.org>
To: pgsql-sql@postgresql.org
To: pgsql-docs@postgresql.org
Subject: PL/pgSQL examples NOT involving functions
Date: 15 Nov 2001 11:49:12 -0500
Message-ID: <m2adxoget3.fsf@tycho.rlent.pnet> (raw)

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



view thread (21+ messages)  latest in thread

Message-ID: <m2adxoget3.fsf@tycho.rlent.pnet>
Permalink:  ../m2adxoget3.fsf@tycho.rlent.pnet/
Also on:    postgresql.org/message-id/m2adxoget3.fsf@tycho.rlent.pnet

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: roland@astrofoto.org, pgsql-sql@postgresql.org
  Subject: Re: PL/pgSQL examples NOT involving functions
  In-Reply-To: <m2adxoget3.fsf@tycho.rlent.pnet>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox