Re: SQL "RETURNING * | output_expression [ [ AS ]" is wrong

From: Julien Rouhaud <rjuju123(at)gmail(dot)com>
To: miguelgilmartinez(at)gmail(dot)com, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: SQL "RETURNING * | output_expression [ [ AS ]" is wrong
Date: 2022-03-21 12:12:10
Message-ID: 20220321121210.pknnj3d4k54ddprw@jrouhaud
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hi,

On Mon, Mar 21, 2022 at 10:09:55AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Hi! AFAIK, UPDATE .... RETURNING works with INTO varname, not AS

I think you're confusing with plpgsql's INTO [1]. The documented syntax works
as expected:

# UPDATE tt SET id = 2 WHERE id = 1 RETURNING id AS new_id;
new_id
--------
2
(1 row)

[1] https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2022-03-21 22:42:40 GENERATED ALWAYS AS - Not Consistent with MD5
Previous Message PG Doc comments form 2022-03-21 10:09:55 SQL "RETURNING * | output_expression [ [ AS ]" is wrong