ST_GEOMCOLLECTION scalar function
The ST_GEOMCOLLECTION function constructs a geometry collection.
If wkt or wkb is null, the result is the null value. An empty geometry collection is not supported.
- wkt
- An expression that returns a character or graphic string value that contains the well-known text (WKT) format of the resulting geometry collection.
- wkb
- An expression that returns a binary string value that contains the well-known binary (WKB) format of the resulting geometry collection.
The result of the function is ST_GEOMCOLLECTION. If the argument is null, the result is the null value.
For details about the supported formats, see WKT and WKB data formats.
Example
The ST_GEOMCOLLECTION function can be used to create and insert a multipoint, multiline, and multipolygon from well-known text representation.
CREATE TABLE sample_geomcollections(id INTEGER,
geometry QSYS2.ST_GEOMCOLLECTION);
INSERT INTO sample_geomcollections(id, geometry) VALUES
(4001, QSYS2.ST_GEOMCOLLECTION('multipoint((1 2), (4 3), (5 6))')),
(4002, QSYS2.ST_GEOMCOLLECTION('multilinestring((33 2, 34 3, 35 6),(28 4, 29 5, 31 8, 43 12),
(39 3, 37 4, 36 7))')),
(4003, QSYS2.ST_GEOMCOLLECTION('multipolygon(((3 3, 4 6, 5 3, 3 3)),
((8 24, 9 25, 1 28, 8 24)),
((13 33, 7 36, 1 40, 10 43, 13 33)))'));
SELECT id, QSYS2.ST_ASTEXT(geometry) AS GeomCollection
FROM sample_geomcollections;
Results:
ID GEOMCOLLECTION
------------ ---------------------------------------------------------------------------------
4001 MULTIPOINT ((1.0 2.0), (4.0 3.0), (5.0 6.0))
4002 MULTILINESTRING ((33.0 2.0, 34.0 3.0, 35.0 6.0),
(28.0 4.0, 29.0 5.0, 31.0 8.0, 43.0 12.0),
(39.0 3.0, 37.0 4.0, 36.0 7.0))
4003 MULTIPOLYGON (((13.0 33.0, 10.0 43.0, 1.0 40.0, 7.0 36.0, 13.0 33.0)),
((3.0 3.0, 5.0 3.0, 4.0 6.0, 3.0 3.0)),
((8.0 24.0, 9.0 25.0, 1.0 28.0, 8.0 24.0)))