Re: [SQL] Updating jsonb rows

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [SQL] Updating jsonb rows
Дата
Msg-id CAKFQuwa5TfW1S9KY8hSRiLDqEPfOuuyh+4Q684iAm8w39CA4ZA@mail.gmail.com
обсуждение исходный текст
Ответ на [SQL] Updating jsonb rows  (Michael Moore <michaeljmoore@gmail.com>)
Ответы Re: [SQL] Updating jsonb rows
Список pgsql-sql
On Fri, Aug 11, 2017 at 6:08 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
​s​
elect jsonb_set(j_final_rslt, '{0,prompt_seq}','99',true) into j_final_rslt;

gives the result:
BEFORE [{"prompt_seq": 150, "attribute_name": "InsuredTimeframe"}, {"prompt_seq": 1200, "attribute_name": "DriverOccupation"}]

AFTER [{"prompt_seq": 99, "attribute_name": "InsuredTimeframe"}, {"prompt_seq": 1200, "attribute_name": "DriverOccupation"}]

How could I change this to ALSO change the attribute_name on the 2nd record to "ABC". The AFTER result would ideally look like:


​This SO post seems like it should get you close.  Basically you pull out the 0th element, concatenate in the values you want to change, and supply that result as the third jsonb_set argument.


David J.

В списке pgsql-sql по дате отправления:

Предыдущее
От: Michael Moore
Дата:
Сообщение: [SQL] Updating jsonb rows
Следующее
От: Michael Moore
Дата:
Сообщение: Re: [SQL] Always getting back a row, even with no results