Re: Merge into does not work - Mailing list pgsql-general

From Ron
Subject Re: Merge into does not work
Date
Msg-id be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com
Whole thread Raw
In response to Merge into does not work  (Shaozhong SHI <shishaozhong@gmail.com>)
List pgsql-general
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 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.

ERROR MESSAGES!  ALWAYS SHOW ERROR MESSAGES!!!

--
Angular momentum makes the world go 'round.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Merge into does not work
Next
From: Tom Lane
Date:
Subject: Re: What do you do with a long running rollback