| From: | Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de> |
|---|---|
| To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | AW: UPDATE myTable SET (myTable.*) = json_populate_record(...) ? |
| Date: | 2026-08-03 15:17:56 |
| Message-ID: | c84d894abc8b4ababe03e1c08255c3b6@stmuk.bayern.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Yes, the least grave of my items can be worked around by wrapping the function into a subselect, for whatever reason this might be necessary.
(As far as I know there are other places in Postgres where I can substitute a subselect by an expression / a function call, and I am curious: Why not here?)
But what about my other item... what about somehow preventing to write all column names, i. e. changing ...
SET (col1, col2, ...)
... to something like ...
SET (myTable.*)
?
My first intention on posting was: Is there some way to acheive that?
If no, my second intention is a general critique on ... I think it is at least similar to what https://carlineng.com/?postid=sql-critique#blog calls " Lack of Orthogonality" in (Postgres-)SQL.
-----Ursprüngliche Nachricht-----
Von: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Gesendet: Montag, 3. August 2026 17:00
An: Färber, Franz-Josef (StMUK) <Franz-Josef(dot)Faerber(at)stmuk(dot)bayern(dot)de>; pgsql-general(at)lists(dot)postgresql(dot)org
Betreff: Re: UPDATE myTable SET (myTable.*) = json_populate_record(...) ?
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2026-08-03 16:15:13 | Re: AW: UPDATE myTable SET (myTable.*) = json_populate_record(...) ? |
| Previous Message | Adrian Klaver | 2026-08-03 15:00:01 | Re: UPDATE myTable SET (myTable.*) = json_populate_record(...) ? |