- SELECT hstore(array_agg('_place_' || key), array_agg(value)) INTO extra_names
- FROM each(location.name - result.name);
- {% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %}
+ IF result.name is null THEN
+ SELECT hstore(array_agg('_place_' || key), array_agg(value))
+ INTO result.name
+ FROM each(location.name);
+ ELSE
+ SELECT hstore(array_agg('_place_' || key), array_agg(value)) INTO extra_names
+ FROM each(location.name - result.name);
+ {% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %}