On 11/26/21 12:10, Alvaro Herrera wrote:
On 2021-Nov-26, Adrian Klaver wrote:
On 11/26/21 11:44, Alvaro Herrera wrote:
On 2021-Nov-26, Shaozhong SHI wrote:
I am using the MERGE patch I posted here[1], on top of Postgres 15.
https://postgr.es/m/20252245.byerxxac444d@alvherre.pgsql
A pat
On 2021-Nov-26, Adrian Klaver wrote:
> On 11/26/21 11:44, Alvaro Herrera wrote:
> > On 2021-Nov-26, Shaozhong SHI wrote:
> >
> > I am using the MERGE patch I posted here[1], on top of Postgres 15.
> >
> > https://postgr.es/m/20252245.byerxxac444d@alvherre.pgsql
>
> A patch that as AFAIK is
On 11/26/21 11:44, Alvaro Herrera wrote:
On 2021-Nov-26, Shaozhong SHI wrote:
I am using the MERGE patch I posted here[1], on top of Postgres 15.
https://postgr.es/m/20252245.byerxxac444d@alvherre.pgsql
A patch that as AFAIK is not even committed to what is at best an alpha
version
On 2021-Nov-26, Shaozhong SHI wrote:
> MERGE INTO Stock USING Buy ON Stock.item_id = Buy.item_id
> WHEN MATCHED THEN UPDATE SET balance = balance + Buy.volume
> WHEN NOT MATCHED THEN INSERT VALUES (Buy.item_id, Buy.volume);
It does work for me:
55479 15devel 680346=# MERGE INTO Stock USING Buy
On 11/26/21 1:08 PM, Shaozhong SHI wrote:
CREATE TABLE Stock(item_id int UNIQUE, balance int);
INSERT INTO Stock VALUES (10, 2200);
INSERT INTO Stock VALUES (20, 1900);CREATE TABLE Buy(item_id int, volume int);
INSERT INTO Buy values(10, 1000);
INSERT INTO Buy values(30, 300);
MERGE INTO Stock
As evidenced by the lack of such a command in our documentation this
doesn't exist. We do offer similar functionality directly as part of the
INSERT command via its ON CONFLICT clause.
David J.