PL/pgSQL examples NOT involving functions

Поиск
Список
Период
Сортировка
От Roland Roberts
Тема PL/pgSQL examples NOT involving functions
Дата
Msg-id m2adxoget3.fsf@tycho.rlent.pnet
обсуждение исходный текст
Ответы 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>)
Список 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 по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Help with INSERT into 2 tables
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: handling exceptions, really not simple... :-((