Re: table aliases with updates

Lists: pgsql-bugs
From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: table aliases with updates
Date: 2000-08-29 23:02:53
Message-ID: 200008292302.e7TN2rw88796@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

andrew brown (andy75(at)hotmail(dot)com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
table aliases with updates

Long Description
It appears that table aliases cannot be used in update queries for the table we are updating.

Sample Code
This doesn't work:

update table1 t1 set value1 = (select value1 from table2 t2 where t2.value2 = t1.value2)

But this does:

update table1 set value1 = (select value1 from table2 t2 where t2.value2 = table1.value2)

No file was uploaded with this report


From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: andy75(at)hotmail(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: table aliases with updates
Date: 2000-08-30 00:09:57
Message-ID: Pine.BSF.4.10.10008291700200.57269-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


This sounds like an enhancement, not a bug per-se. SQL92 seems
to say the below about searched update statements. What
was the error you got from your first query? (I'd guess
a parser error at t1?)

<update statement: searched> ::=
UPDATE <table name>
SET <set clause list>
[ WHERE <search condition> ]

Stephan Szabo
sszabo(at)bigpanda(dot)com

On Tue, 29 Aug 2000 pgsql-bugs(at)postgresql(dot)org wrote:

> andrew brown (andy75(at)hotmail(dot)com) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> table aliases with updates
>
> Long Description
> It appears that table aliases cannot be used in update queries for the table we are updating.
>
> Sample Code
> This doesn't work:
>
> update table1 t1 set value1 = (select value1 from table2 t2 where t2.value2 = t1.value2)
>
> But this does:
>
> update table1 set value1 = (select value1 from table2 t2 where t2.value2 = table1.value2)