UPDATE .. RETURNING OLD.*

Поиск
Список
Период
Сортировка
От Marko Tiikkaja
Тема UPDATE .. RETURNING OLD.*
Дата
Msg-id 4A97F3DE.9050005@cs.helsinki.fi
обсуждение исходный текст
Ответы Re: UPDATE .. RETURNING OLD.*  (David Fetter <david@fetter.org>)
Список pgsql-hackers
Hi everyone,

Today I needed a feature like $subject. The use case was: UPDATE foo SET
bar = bar + 1 WHERE id=$1, but I wanted to only do it when bar was 0. In
order to give the user an informative error message, I also needed to
distinguish the two cases: a row with id = $1 doesn't exist, and bar was
0, so I couldn't put bar != 0 into the WHERE clause. This time I got
around it by using RETURNING bar and checking that it was 1 on the
client side, but I can come up with other cases where you can't do that.

Comments?

Regards,
Marko Tiikkaja








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

Предыдущее
От: "Kevin Grittner"
Дата:
Сообщение: Re: phypot - Pygmy Hippotause ?
Следующее
От: KaiGai Kohei
Дата:
Сообщение: Re: [PATCH] Largeobject access controls