Re: funny update, say update 1, changed 2 records.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Dugan <postgres(at)butterflystitches(dot)com(dot)au>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: funny update, say update 1, changed 2 records.
Date: 2005-06-11 17:29:21
Message-ID: 12097.1118510961@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Neil Dugan <postgres(at)butterflystitches(dot)com(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2005-06-11 18:02:50 memory question
Previous Message Hugo 2005-06-11 17:04:49 Re: how to return a result set from a stored procedure