bUENO, POR AHORA te cuento que pase por alto que en el utlimo query no se retorna un solo valor sino muchos, entonces inclui un tercer ciclo asi:
Código SQL:
Ver originalCREATE OR REPLACE FUNCTION p_update_locales_in_count() RETURNS BOOLEAN AS $BODY$
DECLARE
query_count RECORD;
query_has_locales RECORD;
real_data RECORD;
BEGIN
FOR query_count IN SELECT neighborhood_code,city_code FROM conteo_manzanas_barrio_co LOOP
FOR query_has_locales IN SELECT has_locales FROM sm_city WHERE pk_city = query_count.city_code LOOP
IF query_has_locales.has_locales THEN
FOR real_data IN SELECT pk_locale,name FROM sm_locale WHERE fk_pk_city = query_count.city_code LOOP
UPDATE conteo_manzanas_barrio_co
SET locale_code = real_data.pk_locale, locale_name = real_data.name
WHERE neighborhood_code = query_count.neighborhood_code;
END LOOP;
END IF;
END LOOP;
END LOOP;
RETURNS TRUE;
END $BODY$
LANGUAGE plpgsql;
SI NO FUNCIONA ASI, ENTONCES PROCEDO CON LO QUE QUE ME ACABASTE DE DECIR..
GRACIAS