ST_Geometry

The ST_Geometry function takes a geometry as an input parameter and casts the output type to ST_Geometry.

If the given geometry is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_Geometry(geometry)

Parameter

geometry
A value of one of the seven distinct spatial data types.

Return type

db2gse.ST_Geometry

Examples

The following code example shows how you can use the ST_Geometry function to recast any spatial data type.

SET CURRENT PATH = CURRENT PATH, db2gse; 
CREATE TABLE sample_geometries(id INTEGER, geometry ST_GEOMETRY)  
INSERT INTO sample_geometries(id, geometry) 
       VALUES (7001, ST_Geometry(ST_point ( point(1 2), 1) ) 
INSERT INTO sample_geometries(id, geometry) 
       VALUES (7002, ST_Geometry(ST_line string ( linestring(33 2, 34 3, 
                                                35 6), 1) ) 
INSERT INTO sample_geometries(id, geometry) 
       VALUES (7003, ST_Geometry(ST_polygon ( polygon((3 3, 4 6, 5 3, 
                                            3 3)), 1)))  
SELECT id, cast(ST_AsText (geometry) AS varchar(120)) 
  AS geometry FROM sample_geometries  
Results:
 ID          GEOMETRY          
----------- ----------------------
   7001     POINT ( 1.00000000 2.00000000)
   7002     LINESTRING ( 33.00000000 2.00000000, 34.00000000 3.00000000, 
                       35.00000000 6.00000000)  
   7003     POLYGON (( 3.00000000 3.00000000, 5.00000000 3.00000000, 
                    4.00000000 6.00000000, 3.00000000 3.00000000))