public inbox for [email protected]
help / color / mirror / Atom feedSQL "RETURNING * | output_expression [ [ AS ]" is wrong
2+ messages / 2 participants
[nested] [flat]
* SQL "RETURNING * | output_expression [ [ AS ]" is wrong
@ 2022-03-21 10:09 PG Doc comments form <[email protected]>
2022-03-21 12:12 ` Re: SQL "RETURNING * | output_expression [ [ AS ]" is wrong Julien Rouhaud <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: PG Doc comments form @ 2022-03-21 10:09 UTC (permalink / raw)
To: [email protected]; +Cc: [email protected]
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/14/sql-update.html
Description:
https://www.postgresql.org/docs/14/sql-update.html
Hi! AFAIK, UPDATE .... RETURNING works with INTO varname, not AS
Documentation says:
UPDATE
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table_name [ * ] [ [ AS ] alias ]
SET { column_name = { expression | DEFAULT } |
( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [,
...] ) |
( column_name [, ...] ) = ( sub-SELECT )
} [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
BUT it does not work, it does:
UPDATE
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table_name [ * ] [ [ AS ] alias ]
SET { column_name = { expression | DEFAULT } |
( column_name [, ...] ) = [ ROW ] ( { expression | DEFAULT } [,
...] ) |
( column_name [, ...] ) = ( sub-SELECT )
} [, ...]
[ FROM from_item [, ...] ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ INTO ] output_name ] [, ...] ]
Regards,
Miguel.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: SQL "RETURNING * | output_expression [ [ AS ]" is wrong
2022-03-21 10:09 SQL "RETURNING * | output_expression [ [ AS ]" is wrong PG Doc comments form <[email protected]>
@ 2022-03-21 12:12 ` Julien Rouhaud <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Julien Rouhaud @ 2022-03-21 12:12 UTC (permalink / raw)
To: [email protected]; [email protected]
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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-03-21 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-03-21 10:09 SQL "RETURNING * | output_expression [ [ AS ]" is wrong PG Doc comments form <[email protected]>
2022-03-21 12:12 ` Julien Rouhaud <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox