PL/pgSQL examples NOT involving functions - Mailing list pgsql-sql

From Roland Roberts
Subject PL/pgSQL examples NOT involving functions
Date
Msg-id m2adxoget3.fsf@tycho.rlent.pnet
Whole thread Raw
Responses Re: PL/pgSQL examples NOT involving functions  ("Josh Berkus" <josh@agliodbs.com>)
Re: PL/pgSQL examples NOT involving functions  ("Aasmund Midttun Godal" <postgresql@envisity.com>)
List pgsql-sql
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

pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Help with INSERT into 2 tables
Next
From: "Josh Berkus"
Date:
Subject: Re: handling exceptions, really not simple... :-((