Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nygQL-0000lN-O0 for pgsql-docs@arkaria.postgresql.org; Tue, 07 Jun 2022 21:07:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nygQK-0001hX-Fq for pgsql-docs@arkaria.postgresql.org; Tue, 07 Jun 2022 21:07:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nygQK-0001hO-8D for pgsql-docs@lists.postgresql.org; Tue, 07 Jun 2022 21:07:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nygQH-0005yq-Lz for pgsql-docs@lists.postgresql.org; Tue, 07 Jun 2022 21:07:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 257L7UYE1334779; Tue, 7 Jun 2022 17:07:30 -0400 From: Tom Lane To: "David G. Johnston" cc: s@xss.de, Pg Docs Subject: Re: Mention RETURNING ... INTO target In-reply-to: References: <165462669652.573549.16368658459297802851@wrigleys.postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Tue, 07 Jun 2022 13:47:14 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1334777.1654636050.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 07 Jun 2022 17:07:30 -0400 Message-ID: <1334778.1654636050@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Tue, Jun 7, 2022 at 1:30 PM PG Doc comments form > wrote: >> It looks like INSERT INTO ... RETURNING allows defining a target for th= e >> returned values like SELECT ... INTO does. > That isn't how it works. RETURNING simply turns INSERT into a result se= t > producing SQL Command. And SQL doesn't have a concept of "target" > (variables) in the sense you are thinking. pg/pgsql does, allowing resul= t > set data to be placed into variables. Right. And in fact this *is* documented in the context of pl/pgsql: https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-ST= ATEMENTS-SQL-ONEROW regards, tom lane