Merge into does not work - Mailing list pgsql-general

From Shaozhong SHI
Subject Merge into does not work
Date
Msg-id CA+i5JwZoUVr6CW4F2gCSUMjLHDXOrTWZ6=xwzsXwCjJtKnomtA@mail.gmail.com
Whole thread Raw
Responses Re: Merge into does not work
Re: Merge into does not work
Re: Merge into does not work
List pgsql-general
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 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);
I am using Postgres 9.6.
Regards,
David

pgsql-general by date:

Previous
From: "Godfrin, Philippe E"
Date:
Subject: RE: [EXTERNAL] Re: Inserts and bad performance
Next
From: "David G. Johnston"
Date:
Subject: Re: Merge into does not work