-- geostore/views.sql set search_path to generic, public; create or replace view vgeoattrs as select i.id as item_id, i.geom, i.type, i.name as item_name, i.description as item_description, i.community, a.id as attr_id, p.id as prop_id, p.name as prop_name, p.label as prop_label, p.description as prop_description, p.datatype, p.domain as prop_domain, case when p.datatype = 25 then vl.value else a.txtvalue end as txtvalue, a.intvalue from geoitems i left join geoattrs a on a.item = i.id left join properties p on p.id = a.property left join valuelists vl on p.datatype = 25 and vl.property = p.id and vl.id = a.intvalue;