Re: Update Syntax

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Update Syntax
Дата
Msg-id 20040202174904.GB4402@wolff.to
обсуждение исходный текст
Ответ на Update Syntax  (ramirez@idconcepts.org (Edwin S. Ramirez))
Список pgsql-hackers
On Fri, Jan 30, 2004 at 07:41:18 -0800, "Edwin S. Ramirez" <ramirez@idconcepts.org> wrote:
> Hello,
> 
> I need Postgres support for the following update syntax :
> 
> update table1 set (col1, col2, col3) = (select f1, f2, f3 from table2
> where id=5) where rownum=3;
> 
> update table1 set (col1, col2, col3) = (select f1, f2, f3 from table2
> where id=table1.parentid) where rownum=3;
> 
> These type of update statements are the only ones supported by Oracle
> to update one table from another.

As a work around you could do:
update table1 set col1 = (select f1 from table2 where id=table1.parentid), col2 = (select f2 from table2 where
id=table1.parentid),col3 = (select f3 from table2 where id=table1.parentid) where rownum=3;
 

I don't think this will run as efficiently and it makes the query look
more complex, but it should work for both Oracle and Postgres.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg_restore bug in 7.4.1 ?
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: pg_stat_activity