ST_GEOMETRY scalar function
The ST_GEOMETRY function constructs a geometry from a specified representation.
If wkt or wkb is null, the result is the null value. If wkt is 'POINT EMPTY', an empty geometry is returned. There is no WKB representation for an empty geometry.
- wkt
- An expression that returns a character or graphic string value that contains the well-known text (WKT) format of the resulting geometry.
- wkb
- An expression that returns a binary string value that contains the well-known binary (WKB) format of the resulting geometry.
The result of the function is ST_GEOMETRY. If the argument is null, the result is the null value.
For details about the supported formats, see WKT and WKB data formats.
Example
Use the ST_GEOMETRY function to construct a point, a linestring, and a polygon.
CREATE TABLE sample_geometries(id INTEGER, geometry QSYS2.ST_GEOMETRY);
INSERT INTO sample_geometries(id, geometry) VALUES
(7001, QSYS2.ST_GEOMETRY('point(1 2)')),
(7002, QSYS2.ST_GEOMETRY('linestring(33 2, 34 3, 35 6)')),
(7003, QSYS2.ST_GEOMETRY('polygon((3 3, 4 6, 5 3, 3 3))'));
SELECT id, QSYS2.ST_ASTEXT(geometry) AS geometry
FROM sample_geometries;
Results:
ID GEOMETRY
------ ------------------------------------------------
7001 POINT (1.0 2.0)
7002 LINESTRING (33.0 2.0, 34.0 3.0, 35.0 6.0)
7003 POLYGON ((3.0 3.0, 5.0 3.0, 4.0 6.0, 3.0 3.0))
