pggeodb-preprod.nancy.inra.fr/db_onf_gde - db_onf_gde on pggeodb-preprod.nancy.inra.fr
Previous topic Chapter index Next topic

Function: topogeom_addelement

 

 

Schema

topology

 

Owner

postgres

 

Descriptions

args: tg, el - Add an element to the definition of a TopoGeometry

 

Options

Option

Value

Returns

topology.topogeometry

Language

plpgsql

Parameters

tg topology.topogeometry

in el topology.topoelement

 

Definition

CREATE OR REPLACE FUNCTION topology.topogeom_addelement (
 tg topology.topogeometry,
 el topology.topoelement
)
RETURNS topology.topogeometry AS
$span$
DECLARE

 toponame TEXT;
 sql TEXT;
BEGIN

 -- Get topology name
 BEGIN
   SELECT name
   FROM
topology.topology
     INTO STRICT toponame WHERE id = topology_id(tg);
 EXCEPTION
   WHEN
NO_DATA_FOUND THEN
     RAISE EXCEPTION
'No topology with name "%" in topology.topology',
       atopology;
 END;

 -- Insert new element
 sql := format('INSERT INTO %s.relation'
        '(topogeo_id,layer_id,element_id,element_type)'
        ' VALUES($1,$2,$3,$4)'
, quote_ident(toponame));
 BEGIN
   EXECUTE
sql USING id(tg), layer_id(tg), el[1], el[2];
 EXCEPTION
   WHEN
unique_violation THEN
     -- already present, let go
   WHEN OTHERS THEN
     RAISE EXCEPTION
'Got % (%)', SQLERRM, SQLSTATE;
 END;

 RETURN tg;

END
$span$
LANGUAGE
'plpgsql'
VOLATILE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST
100;

COMMENT ON FUNCTION topology.topogeom_addelement(tg topology.topogeometry, el topology.topoelement)
IS 'args: tg, el - Add an element to the definition of a TopoGeometry';

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 07/12/2018 13:23
Previous topic Chapter index Next topic