Re: funny update, say update 1, changed 2 records. - Mailing list pgsql-general

From Tom Lane
Subject Re: funny update, say update 1, changed 2 records.
Date
Msg-id 12097.1118510961@sss.pgh.pa.us
Whole thread Raw
In response to funny update, say update 1, changed 2 records.  (Neil Dugan <postgres@butterflystitches.com.au>)
Responses Re: funny update, say update 1, changed 2 records.  (Neil Dugan <postgres@butterflystitches.com.au>)
List pgsql-general
Neil Dugan <postgres@butterflystitches.com.au> writes:
> I have been having some trouble with a particular table view.  An UPDATE
> command is not only changing the applicable record it is also creating a
> new record as well.

I think it's because your UPDATE is updating supplier.account_type which
is part of the join key for the view's underlying join.  Somehow that
results in the update applying to all supplier rows that join to the
same account_type row.  Don't have time now to work out exactly why ...
but the easiest solution is probably to not use a join in the view.
Instead fetch the account_type.name via a subselect in the view's
output list.

            regards, tom lane

pgsql-general by date:

Previous
From: Hugo
Date:
Subject: Re: how to return a result set from a stored procedure
Next
From: "Ed L."
Date:
Subject: memory question