Converts the geometry to a polygon.
SELECT NEW ST_GeomCollection().ST_ToPolygon()
The following returns an error because the Shape column is of type ST_Geometry and ST_Geometry does not support the ST_Area method.
SELECT Shape.ST_Area() FROM SpatialShapes WHERE ShapeID = 22
The following uses ST_ToPolygon to change the type of the Shape column expression to ST_Polygon. ST_Area returns the result 12.5.
SELECT Shape.ST_ToPolygon().ST_Area() FROM SpatialShapes WHERE ShapeID = 22
In this case, the value of the Shape column is known be of type ST_Polygon, so TREAT can be used to efficiently change the type of the expression. ST_Area returns the result 12.5.
SELECT TREAT( Shape AS ST_Polygon ).ST_Area() FROM SpatialShapes WHERE ShapeID = 22
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.33