The following returns all rows in SpatialShapes containing rings. The IF expression is required to ensure the TREAT function
is not executed if the Shape is not a subtype of ST_Curve. Without the IF expression the server may reorder the conditions
in the WHERE clause, leading to an error.
SELECT * FROM SpatialShapes
WHERE IF Shape IS OF ( ST_Curve )
AND TREAT( Shape AS ST_Curve ).ST_IsRing() = 1 THEN 1 ENDIF = 1
The following returns all rows in curve_table that have geometries that are rings. This example assumes the geometry column
has type ST_Curve, ST_LineString, ST_CircularString or ST_CompoundCurve.
SELECT * FROM curve_table WHERE geometry.ST_IsRing() = 1