Re: request for sql3 compliance for the update command

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Justin Clift <justin(at)postgresql(dot)org>, Dave Cramer <dave(at)fastcrypt(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: request for sql3 compliance for the update command
Date: 2003-02-20 09:56:39
Message-ID: 1045734999.1397.3.camel@fuji.krosing.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian kirjutas N, 20.02.2003 kell 06:16:
> Agreed folks are going to have bigger problems from Informix than just
> this, and in fact I used Informix for years and didn't know they allowed
> this.
>
> However, what solution do we have for UPDATE (coll...) = (select val...)
> for folks? It is awkward to repeat a query multiple times in an UPDATE.

hannu=# create table target (id serial, a int, b int, c int);
NOTICE: CREATE TABLE will create implicit sequence 'target_id_seq' for
SERIAL column 'target.id'
CREATE TABLE
hannu=# insert into target(a,b,c) values (0,0,0);
INSERT 16983 1
hannu=# insert into target(a,b,c) values (1,1,1);
INSERT 16984 1
hannu=# update target set
hannu-# a = source.a1, b=source.a2, c=source.a3
hannu-# from (select 1 as a1, 2 as a2, 3 as a3 ) as source
hannu-# where id = 1
hannu-# ;
UPDATE 1
hannu=# select * from target;
id | a | b | c
----+---+---+---
2 | 1 | 1 | 1
1 | 1 | 2 | 3
(2 rows)

hannu=#

--------------
Hannu

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2003-02-20 10:00:14 Re: request for sql3 compliance for the update command
Previous Message Hannu Krosing 2003-02-20 09:43:18 Re: request for sql3 compliance for the update command