Re: [DOCS] PL/pgSQL examples NOT involving functions

Поиск
Список
Период
Сортировка
От Christopher Kings-Lynne
Тема Re: [DOCS] PL/pgSQL examples NOT involving functions
Дата
Msg-id GNELIHDDFBOCMGBFGEFOGEHLCAAA.chriskl@familyhealth.com.au
обсуждение исходный текст
Ответ на 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;

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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Andriy Pyrozhenko
Дата:
Сообщение: Question
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: INDEXng date_trunc ...