Re: request for sql3 compliance for the update command - Mailing list pgsql-hackers

From Greg Stark
Subject Re: request for sql3 compliance for the update command
Date
Msg-id 87ptom9a3y.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: request for sql3 compliance for the update command  (Hannu Krosing <hannu@tm.ee>)
List pgsql-hackers
Hannu Krosing <hannu@tm.ee> writes:

> the more accurate (nonstandard) syntax could have been
> 
> SELECT src.val,
>        tgt.val 
>   FROM updatesrc as src FOR UPDATE,
>        updatetgd as tgt
>  WHERE src.id = tgt.id
>    SET src.val = tgt.val
> ;

The syntax in Oracle, for example, would be not very different:

UPDATE (       SELECT src.id, src.val, tgt.val as newval         FROM udpatesrc AS src,               updatetgd AS tgt
     WHERE src.id = tgt.id      )  SET val = newval
 

This only works if src.id is declared as a primary key.

I'm not sure if this is blessed by any standard.
It's certainly extremely useful.

-- 
greg



pgsql-hackers by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: Nested transactions: low level stuff
Next
From: Hiroshi Inoue
Date:
Subject: Re: cursors outside transactions