do $$
declare
	var_reprocessar record;
begin
	for var_reprocessar in(
				select 
					ode.odeid as odeid
				from 
					par.omissodeclarado ode 
				where 
					ode.odedata < '2025-06-10' 
					and ode.prpid not in(
						select 
							distinct prp.prpid 
						from 
							par.edicaodeclaracaoomissao edm
							inner join par.omissodeclarado ode on edm.odeid = ode.odeid
							inner join par.processopar prp on prp.prpid = ode.prpid 
					)
	)
	loop
		raise notice 'Declaração que irão reprocesssar ode.odeid = %', var_reprocessar.odeid;	
		update par.omissodeclarado set odestatus='I' where odeid = var_reprocessar.odeid;
	end loop;
end;
$$;