Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCnjU-0001kO-Mg for pgsql-admin@arkaria.postgresql.org; Tue, 24 Sep 2019 16:32:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iCnjT-0004vP-Da for pgsql-admin@arkaria.postgresql.org; Tue, 24 Sep 2019 16:32:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCnjS-0004vI-OY for pgsql-admin@lists.postgresql.org; Tue, 24 Sep 2019 16:32:07 +0000 Received: from resqmta-ch2-07v.sys.comcast.net ([2001:558:fe21:29:69:252:207:39]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iCnjO-0001OM-Ht for pgsql-admin@postgresql.org; Tue, 24 Sep 2019 16:32:06 +0000 Received: from resomta-ch2-08v.sys.comcast.net ([69.252.207.104]) by resqmta-ch2-07v.sys.comcast.net with ESMTP id CnHKic89sWy6XCnjKifRxr; Tue, 24 Sep 2019 16:31:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1569342718; bh=seeZuM3jMwx50bunq6snrrv/mOYgWv4QNY+X0iyJsnQ=; h=Received:Received:To:From:Subject:Message-ID:Date:MIME-Version: Content-Type; b=KJSw1B/nW/gT7b9opU6fDO+Teqh9dE8Bu+q6L8VKFUXrNXzZfLUKBLWnohVVN4UUQ dgVk+ZarryIohwvt3JINxv9KdCYvAxQTiIteXE5Q719W6hrNboTY+TY/G/YgpjtyJ7 8+YvVhS5h00vIRTG4zsEEYNoal2ufEbtRFt9/vnvm3B3hI/GK75CL+M51TTmThzFVc RJ9KnS8m0wSUJ7tT41/i507GkqzfRrMkCqjbZ124FiuPIlsRMbplFSJmr8gxb2SveZ sgDIK8XH4WP02MtbKo3kbNWIeW6UesM37kZFUF4lW4i0FI1wVwtynW9aLMtqivYn35 aSPvQdiE084/w== Received: from [IPv6:2601:19c:4702:1a94:3551:d146:9d71:a5f6] ([IPv6:2601:19c:4702:1a94:3551:d146:9d71:a5f6]) by resomta-ch2-08v.sys.comcast.net with ESMTPSA id CnjIiHcvOPR8vCnjJinddO; Tue, 24 Sep 2019 16:31:57 +0000 X-Xfinity-VMeta: sc=0;st=legit To: pgsql-admin@postgresql.org From: George Neuner Subject: Re: Merge statement Message-ID: <7a6db92e-0ddc-89e8-7f7e-dae04ddad6bd@comcast.net> Date: Tue, 24 Sep 2019 12:31:53 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------07E24FF0B6E84902B233B1BC" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------07E24FF0B6E84902B233B1BC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On Mon, 23 Sep 2019 15:48:06 +0000 (UTC), Pepe TD Vo wrote: >Yes, I heard  MERGE is not a command in Postgres but the others said >merge statement added stored procedures in version 11 > >I upgraded my postgresql from 10.6 to 11.1. in AWS, still not work. >thank you, >Bach-Nga You misunderstood. Postrgesql added stored procedures in version 11.  Unlike stored /functions/ (which PG has had forever), stored procedures allow transactions within their code. This is similar to the stored procedures in Oracle and it helps with Oracle -> Postgresql conversions. However, Postgresql does NOT and never did have a MERGE command. The "documentation" page you discovered was just a proposal for an implementation that never happened. Postgresql can detect conflicts on INSERT and perform an UPDATE instead (see https://www.postgresql.org/docs/current/sql-insert.html).  This is not exactly the same as Oracle's MERGE so you'll have to study it carefully to make you understand the nuances and be sure it works as intended in your application ... but it is the closest you can get using Postgresql. George --------------07E24FF0B6E84902B233B1BC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On Mon, 23 Sep 2019 15:48:06 +0000 (UTC), Pepe TD Vo <pepevo@yahoo.com> wrote:

>Yes, I heard  MERGE is not a command in Postgres but the others said
>merge statement added stored procedures in version 11
>
>I upgraded my postgresql from 10.6 to 11.1. in AWS, still not work.
>thank you,
>Bach-Nga

You misunderstood.

Postrgesql added stored procedures in version 11.  Unlike stored functions (which PG has had forever), stored procedures allow transactions within their code. This is similar to the stored procedures in Oracle and it helps with Oracle -> Postgresql conversions.

However, Postgresql does NOT and never did have a MERGE command.  The "documentation" page you discovered was just a proposal for an implementation that never happened.

Postgresql can detect conflicts on INSERT and perform an UPDATE instead (see  https://www.postgresql.org/docs/current/sql-insert.html).  This is not exactly the same as Oracle's MERGE so you'll have to study it carefully to make you understand the nuances and be sure it works as intended in your application ... but it is the closest you can get using Postgresql.

George --------------07E24FF0B6E84902B233B1BC--