Re: re-novice coming back to pgsql: porting an SQLite update statement to postgres
От | Dan Kortschak |
---|---|
Тема | Re: re-novice coming back to pgsql: porting an SQLite update statement to postgres |
Дата | |
Msg-id | 48019d21fd7c669afb83161337f7e007ae619534.camel@kortschak.io обсуждение исходный текст |
Ответ на | Re: re-novice coming back to pgsql: porting an SQLite update statement to postgres (Alban Hertroys <haramrae@gmail.com>) |
Ответы |
Re: re-novice coming back to pgsql: porting an SQLite update statement to postgres
|
Список | pgsql-general |
On Sat, 2024-09-14 at 12:05 +0200, Alban Hertroys wrote: > > That’s because the replacement data is an array of objects, not a > single object. > > You need to iterate through the array elements to build your > replacement data, something like what I do here with a select > (because that’s way easier to play around with): > > with dollar6 as ( > select jsonb($$[ > { > "data": { > "foo": 1, "bar": 2 > }, > "end": "2023- > 06-12T19:54:51Z", > "start": > "2023-06-12T19:54:39Z" > } > ]$$::text) replacement > ) > select * > from dollar6 > cross join lateral jsonb_array_elements(replacement) r > where (r->>'start')::timestamptz <= current_timestamp; Thanks
В списке pgsql-general по дате отправления: