UPDATE .. RETURNING OLD.* - Mailing list pgsql-hackers

From Marko Tiikkaja
Subject UPDATE .. RETURNING OLD.*
Date
Msg-id 4A97F3DE.9050005@cs.helsinki.fi
Whole thread Raw
Responses Re: UPDATE .. RETURNING OLD.*  (David Fetter <david@fetter.org>)
List 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 by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: phypot - Pygmy Hippotause ?
Next
From: KaiGai Kohei
Date:
Subject: Re: [PATCH] Largeobject access controls