public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Ray O'Donnell <[email protected]>
Cc: 'PostgreSQL' <[email protected]>
Subject: Re: Combining scalar and row types in RETURNING
Date: Tue, 03 Jun 2025 15:31:34 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <01020197370480a4-f9b53911-e5a8-4bdb-81e5-de41d5db4d8c-000000@eu-west-1.amazonses.com>
References: <01020197369aac89-01a7b7b4-b775-471e-ac8e-de8b28d87008-000000@eu-west-1.amazonses.com>
<[email protected]>
<01020197370480a4-f9b53911-e5a8-4bdb-81e5-de41d5db4d8c-000000@eu-west-1.amazonses.com>
"Ray O'Donnell" <[email protected]> writes:
> (iii) Running (ii) but with the order of the items in RETURNING reversed -
> ... returning t, merge_action() into m_new, m_action
> - gave me a different error:
> ERROR: record variable cannot be part of multiple-item INTO list
> LINE 53: m, merge_action() into m_new, m_action
> ...which seems to answer my question definitively.
Ah, after looking at the source code in that area, plpgsql
allows the INTO target to be either a single composite
variable, or one or more non-composite variables; the
argument being that otherwise it's too hard to decide which
RETURNING items match which INTO items.
But I think maybe there is still a solution:
declare
m_into record;
...
returning
merge_action() m, t
into
m_into;
... then fetch m_into.m and m_into.t (the latter will be
a composite field). I didn't try this approach though.
regards, tom lane
view thread (3+ messages)
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Combining scalar and row types in RETURNING
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox