Re: Combining scalar and row types in RETURNING - Mailing list pgsql-general

From Tom Lane
Subject Re: Combining scalar and row types in RETURNING
Date
Msg-id 877615.1748979094@sss.pgh.pa.us
Whole thread Raw
In response to Re: Combining scalar and row types in RETURNING  (Ray O'Donnell <ray@rodonnell.ie>)
List pgsql-general
"Ray O'Donnell" <ray@rodonnell.ie> 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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Combining scalar and row types in RETURNING
Next
From: David Rowley
Date:
Subject: Re: Sudden increase in n_dead_tup with no corresponding insert/update/delete