ST_IsValid takes an ST_Geometry and returns 1 (TRUE) if it is valid, otherwise it returns 0 (FALSE). A geometry inserted into a DB2 database will always be valid because the DB2 Spatial Extender always validates its spatial data before accepting it. However, other DBMS vendors may not validate the input, but instead require that the application do so.
Syntax
db2gse.ST_IsValid(g db2gse.ST_Geometry)
Return type
Integer
Examples
The valid_test table is created with the columns geotype and g1. The geotype column stores the name of the geometry subclass stored in the g1 geometry column.
CREATE TABLE valid_test (geotype varchar(20), g1 db2gse.ST_Geometry)
The INSERT statements inserts a sample subclass into the valid_test table.
INSERT INTO valid_test VALUES( 'Point', db2gse.ST_PointFromText('point (10.02 20.01)', db2gse.coordref()..srid(0)) ) INSERT INTO valid_test VALUES( 'Linestring', db2gse.ST_LineFromText('linestring (10.02 20.01,10.32 23.98,11.92 25.64)', db2gse.coordref()..srid(0)) ) INSERT INTO valid_test VALUES( 'Polygon', db2gse.ST_PolyFromText('polygon ((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01))', db2gse.coordref()..srid(0)) ) INSERT INTO valid_test VALUES( 'Multipoint', db2gse.ST_MPointFromText('multipoint (10.02 20.01,10.32 23.98, 11.92 25.64)', db2gse.coordref()..srid(0)) ) INSERT INTO valid_test VALUES( 'Multilinestring', db2gse.ST_MLineFromText('multilinestring ((10.02 20.01, 10.32 23.98,11.92 25.64),(9.55 23.75,15.36 30.11))', db2gse.coordref()..srid(0)) ) INSERT INTO valid_test VALUES( 'Multipolygon', db2gse.ST_MPolyFromText('multipolygon (((10.02 20.01,11.92 35.64,25.02 34.15, 19.15 33.94,10.02 20.01)),((51.71 21.73,73.36 27.04,71.52 32.87, 52.43 31.90,51.71 21.73)))', db2gse.coordref()..srid(0)) )
The SELECT statement lists the subclass name stored in the geotype column with the dimension of that geotype.
SELECT geotype, db2gse.ST_IsValid(g1) Valid FROM valid_test
GEOTYPE Valid -------------------- ------------- ST_Point 1 ST_Linestring 1 ST_Polygon 1 ST_Multipoint 1 ST_Multilinestring 1 ST_Multipolygon 1 6 record(s) selected.