How can I test if a PostGIS topology with a given name exists? I don't want to run into error when creating the topology with:
SELECT topology.CreateTopology('topology_name', 1);
How can I test if a PostGIS topology with a given name exists? I don't want to run into error when creating the topology with:
SELECT topology.CreateTopology('topology_name', 1);
SELECT topology.CreateTopology('topology_name', 1)
WHERE NOT EXISTS (
SELECT * FROM topology.topology WHERE name = 'topology_name'
);
I'm assuming you have a custom spatial_ref_sys
record with SRID=1
or the creation statement would fail not finding that SRID
.
You can try to use a conditional expression and topology.GetTopologyID
, e.g.:
SELECT COALESE(topology.GetTopologyID('topology_name'), topology.CreateTopology('topology_name', 1)) AS topo_id;