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

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

On Sat, 2005-06-11 at 13:29 -0400, Tom Lane wrote:
> 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

Hi Tom Lane,

Thanks for the reply, something doesn't sound right here. How can an
update cause a new record to be created (id = 6) as well as updating the
correct record (id = 3)?

I am not sure what you mean by 'subselect' in the views output list.
Isn't that what I am doing in creating the view?

Regards Neil

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tatsuo Ishii 2005-06-12 03:24:30 Re: PostgreSQL Certification
Previous Message Tom Lane 2005-06-11 23:59:25 Re: memory question