pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Merge into does not work
Date: Fri, 26 Nov 2021 13:41:03 -0600
Message-ID: <be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com> (raw)
In-Reply-To: <CA+i5JwZoUVr6CW4F2gCSUMjLHDXOrTWZ6=xwzsXwCjJtKnomtA@mail.gmail.com>
References: <CA+i5JwZoUVr6CW4F2gCSUMjLHDXOrTWZ6=xwzsXwCjJtKnomtA@mail.gmail.com>

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.

view thread (7+ messages)  latest in thread

Message-ID: <be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com>
Permalink:  ../be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com/
Also on:    postgresql.org/message-id/be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Merge into does not work
  In-Reply-To: <be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com>
  References: <CA+i5JwZoUVr6CW4F2gCSUMjLHDXOrTWZ6=xwzsXwCjJtKnomtA@mail.gmail.com> <be436264-0d90-0245-d86a-06c85fe6e0f3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox