Re: Insert works but fails for merge

Поиск
Список
Период
Сортировка
От Greg Sabino Mullane
Тема Re: Insert works but fails for merge
Дата
Msg-id CAKAnmmK2iECtmatmiOq_JE03K5dFPmugy_CqbGAs-SR-3U1bbw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Insert works but fails for merge  (Greg Sabino Mullane <htamfids@gmail.com>)
Список pgsql-general
I just remembered that one of the complaints was not wanting to worry about looking up the data types. In my previous example, you can also leave out the types and Postgres will do the right thing. I prefer the explicit data type version for clarity, but though I would provide this one for completeness:

prepare foo as with x as (update tab1 set mid=$2 where id=$1 returning 1)
  insert into tab1 select $1,$2,$3 where not exists (select 1 from x);

Cheers,
Greg

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