set search_path = "fs09000000_mod_inventory_storage", "public"; do $$ declare partition_to_process uuid := '00000000-0000-0000-0000-000000000000'::uuid; range_rec public.uuid_range%rowtype; begin for range_rec in select ur.* from public.uuid_range ur where ur.partition = partition_to_process and ur.completed = false loop -- start transaction; UPDATE fs09000000_mod_inventory_storage.instance i SET complete_updated_date = (jsonb -> 'metadata' ->> 'updatedDate')::timestamp with time zone where i.id between range_rec.subrange_start and range_rec.subrange_end; update public.uuid_range set completed = true where id = range_rec.id; -- raise notice 'subrange id: % completed', range_rec.id; commit; end loop; end $$;