
				/*вставка сквозного порядкового номера случая в объединенном реестре*/
				WITH t AS 
				(
					SELECT registry_id, evn_id, dense_rank () OVER (ORDER BY registry_id, evn_id) AS n_zap
							FROM r7.registrydata 
							WHERE registry_id = any(r7.p_registry_get_registry_id_arr($1))
							order by registry_id
				)
				UPDATE r7.registrydata AS f
				SET
					region_data = f.region_data || jsonb_build_object('n_zap',t.n_zap::integer)
				FROM t
				WHERE
					f.registry_id = t.registry_id and f.evn_id = t.evn_id
				
