do $$

declare
	v_array_obraprocessos TEXT[];
	v_record_declaracao RECORD;
begin
	
	FOR v_record_declaracao in(
	        SELECT
				 pro.pronumeroprocesso, ode.odeid, odc.odcid
			FROM par.omissodeclarado_confirmado odc
	        INNER JOIN par.omissodeclarado ode ON ode.odeid = odc.odeid
	        INNER JOIN par.processoobraspar pro ON pro.proid = ode.proid_par
	        WHERE odc.odctipo_programa = 'OBRA'
	            AND odc.odcnumeroprocesso = ''
		)
    LOOP
		update par.omissodeclarado_confirmado set odcnumeroprocesso = v_record_declaracao.pronumeroprocesso where odeid = v_record_declaracao.odeid and odcid = v_record_declaracao.odcid;
		raise notice 'numprocesso = %, odeid = %, odcid = %',v_record_declaracao.pronumeroprocesso, v_record_declaracao.odeid, v_record_declaracao.odcid ;

    END LOOP;

end; $$
