ST_GeometryType function

The ST_GeometryType function takes a geometry as input parameter and returns the fully qualified type name of the dynamic type of that geometry.

The functions TYPE_SCHEMA and TYPE_NAME have the same effect.

This function can also be called as a method.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_GeometryType(geometry)

Parameter

geometry
A value of type ST_Geometry for which the geometry type is to be returned.

Return type

VARCHAR(128)

Examples

The following code illustrates how to determine the type of a geometry.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE sample_geometries (id INTEGER, geometry ST_GEOMETRY)

INSERT INTO sample_geometries(id, geometry)
VALUES
    (7101, ST_Geometry('point(1 2)', 1) ),
    (7102, ST_Geometry('linestring(33 2, 34 3, 35 6)', 1) ),
    (7103, ST_Geometry('polygon((3 3, 4 6, 5 3, 3 3))', 1)),
    (7104, ST_Geometry('multipoint(1 2, 4 3)', 1) )

SELECT id, geometry..ST_GeometryType AS geometry_type
FROM   sample_geometries

Results:

ID          GEOMETRY_TYPE
----------- -------------------------------
       7101 "DB2GSE  "."ST_POINT"
       7102 "DB2GSE  "."ST_LINESTRING"
       7103 "DB2GSE  "."ST_POLYGON"
       7104 "DB2GSE  "."ST_MULTIPOINT"