Re: [GENERAL] Do not INSERT if UPDATE fails

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [GENERAL] Do not INSERT if UPDATE fails
Дата
Msg-id CAKFQuwZn=_qwX43A+bOEcB3GVXO34nE5TJ8u6V0vRcjx7+MaKA@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] Do not INSERT if UPDATE fails  (Alexander Farber <alexander.farber@gmail.com>)
Ответы Re: [GENERAL] Do not INSERT if UPDATE fails
Список pgsql-general
On Wed, Aug 2, 2017 at 8:58 AM, Alexander Farber <alexander.farber@gmail.com> wrote:
However if the user record is not found or the user already has vip_until >= CURRENT_TIMESTAMP (i.e. the user has already purchased "vip status") I would like to cancel the INSERT.

 
​You can "join" two DDL commands by using a Common Table Expression (CTE) (i.e., WITH / SELECT)​.  You would need to make it so the UPDATE happens first and if there are no results the INSERT simply becomes a no-op.

David J.

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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [GENERAL] Would you add a --dry-run to pg_restore?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Would you add a --dry-run to pg_restore?