Re: [HACKERS] update and select - Mailing list pgsql-hackers

From Thomas G. Lockhart
Subject Re: [HACKERS] update and select
Date
Msg-id 36400164.4ADB4648@alumni.caltech.edu
Whole thread Raw
In response to update and select  (Michael Meskes <meskes@usa.net>)
Responses Re: [HACKERS] update and select  (Michael Meskes <meskes@usa.net>)
List pgsql-hackers
> In Oracle I'd be able to write:
> update test set c = (select c from test where i = 1) where i = 0;
> Is it correct that we do not allow this?

That is correct, and it is on the ToDo list as something like "allow
subselects in target expressions" (though I'm not finding it when I
look).

However, as you suspect you can rephrase it:

tgl=> update x set c = j.c from x as j where j.i = 1 and x.i = 0;
UPDATE 1
tgl=> select * from x;
i|c
-+-
1|T
2|A
0|T
(3 rows)
                   - Tom


pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] A small problem with the new inet and cidr typesg
Next
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Warning!!