"Ray O'Donnell" <r...@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