Re: Partial update on an postgres upsert violates constraint

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Partial update on an postgres upsert violates constraint
Дата
Msg-id 29141.1479932382@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Partial update on an postgres upsert violates constraint  (Andreas Terrius <gotenwinz99@gmail.com>)
Список pgsql-general
Andreas Terrius <gotenwinz99@gmail.com> writes:
> Is there any way to check whether the row already exists before checking
> constraints ? I still want it to fail if it turns out to be a new row
> (which would violate the not null constraint), but updates the row if it
> already exists.

I'm not really sure why you expect this to be able to work.  The data
you are supplying is insufficient to satisfy the INSERT case, so why do
you think that an insert-or-update should be possible?

ISTM that you could try the UPDATE first and notice whether it updates
any rows or not.  I'm not sure what you're going to do if it doesn't,
though, since you still haven't got enough data to do an INSERT.

            regards, tom lane


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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Backup "Best Practices"
Следующее
От: Poul Kristensen
Дата:
Сообщение: Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used