Re: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
Date: 2026-08-03 15:00:01
Message-ID: a0519983-dfc1-4660-be0e-985b07bfae02@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8/3/26 12:09 AM, Färber, Franz-Josef (StMUK) wrote:
> Dear Postgres Community,
>
> cf. https://www.postgresql.org/docs/current/sql-update.html :
>
> As far as I understand, I can
>
> * UPDATE myTable SET col1 = val1, col2 = val2, ...
> * UPDATE myTable SET (col1, col2, ...) = <ROW-or-subselect>
>
> But I cannot, and I am missing that:
> * UPDATE myTable SET (myTable.*) = <ROW-or-subselect>
> * UPDATE myTable SET (col1, col2, ...) = json_populate_record(NULL::myTable, myJson) -- this is a function, not a ROW construct and not a subselect

Make it a subselect? Not tested but:

UPDATE myTable SET (col1, col2, ...) = (select * from
json_populate_record(NULL::myTable, myJson))

>
> This would be useful for some of my trigger code.
>
>
> Regards,
> fjf2002
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message 2026-08-03 15:17:56 AW: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
Previous Message Daniel Gustafsson 2026-08-03 12:09:18 Re: Adoption vs mail rates