From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Miles Elam <miles(dot)elam(at)productops(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: RETURNING to_jsonb(...) |
Date: | 2020-05-05 20:25:30 |
Message-ID: | 7a2ec151-954a-e949-65a1-331732547baf@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 5/5/20 1:11 PM, Miles Elam wrote:
> How can the new record returned from RETURNING to converted to jsonb?
>
> For example something like:
>
> INSERT INTO my_table (a, b, c) VALUES ('a', 'b', 'c')
> RETURNING to_jsonb(*);
>
>
> or
>
> UPDATE my_table SET a = 'a'
> RETURNING to_jsonb(*);
>
>
> or
>
> INSERT INTO my_table (a, b, c) VALUES ('a', 'b', 'c')
>
> ON CONFLICT DO UPDATE SET a = EXCLUDED.a
>
> RETURNING to_jsonb(*);
>
>
insert into sample_tbl values(3, 2) returning to_jsonb(sample_tbl.*);
to_jsonb
-----------------------------------
{"sample_id": 3, "freezer_fk": 2}
(1 row)
>
> Thanks in advance
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2020-05-05 20:46:11 | Re: Lock Postgres account after X number of failed logins? |
Previous Message | Tom Lane | 2020-05-05 20:18:02 | Re: PostgreSQL client hangs sometimes on 'EXEC SQL PREPARE sid_sisisinst FROM :select_anw;' |