| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Ray O'Donnell" <ray(at)rodonnell(dot)ie> |
| Cc: | "'PostgreSQL'" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Combining scalar and row types in RETURNING |
| Date: | 2025-06-03 16:53:58 |
| Message-ID: | 858949.1748969638@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
"Ray O'Donnell" <ray(at)rodonnell(dot)ie> writes:
> Can you combine scalar and row types in a RETURNING clause?
I think so.
> declare
> m_action text;
> m_new_data record;
> begin
> merge into my_table t
> using (
> ....
> ) s
> on (t.id = s.id)
> when matched then
> update .....
> when not matched then
> insert .....
> returning
> merge_action(), t.*
> into
> m_action, m_new_data;
I think the problem here is that "t.*" gets expanded into a list of
all of t's columns, just as would happen in a SELECT's output list.
Try
returning merge_action(), t
It might also be necessary to declare the target variable
"m_new_data" as being of type my_table rather than generic
"record"; not sure about that.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ray O'Donnell | 2025-06-03 18:18:51 | Re: Combining scalar and row types in RETURNING |
| Previous Message | Ray O'Donnell | 2025-06-03 16:23:15 | Combining scalar and row types in RETURNING |