On 03/06/2025 20:01, Adrian Klaver wrote:
> On 6/3/25 11:18, Ray O'Donnell wrote:
>> On 03/06/2025 17:53, Tom Lane wrote:
>
>> Thanks a million for the explanation, Tom - that makes sense. I tried
>> what you suggested, with mixed results:
>>
>> (i) Running the MERGE as a stand-alone query, with just RETURNING...
>> , worked - I got a scalar and a row as expected.
>>
>> (ii) Running it in a function (actually a DO block), with m_new
>> correctly declared as the table type, failed with the same error as
>> before.
>>
>> (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.
>
> This:
>
> ... returning t, merge_action() into m_new, m_action
>
> does not match this:
>
> LINE 53: m, merge_action() into m_new, m_action
>
>
> Is this a copy and paste error or two different invocations of the
> function?
Whoops, sorry, yes, that's a copy-and-paste error - the target table is
aliased as "m" in my original.
Ray.
--
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie