ST_WKTTOSQL scalar function
The ST_WKTTOSQL function takes a well-known text (WKT) format of a geometry and returns the corresponding geometry.
If wkt is null, the result is the null value. If wkt is 'POINT EMPTY', an empty geometry is returned. For details about the supported formats, see WKT and WKB data formats
The ST_WKTTOSQL function is identical to the ST_GEOMETRY(wkt) function.
- wkt
- A value of type VARCHAR or CLOB that contains the WKT format of the resulting geometry.
The result of the function is ST_GEOMETRY.
Example
Use the ST_WKTTOSQL to create and insert geometries using their well-known text representations.
CREATE TABLE sample_geometries (id INTEGER, geometry QSYS2.ST_GEOMETRY);
INSERT INTO sample_geometries
VALUES (10, QSYS2.ST_WKTTOSQL('point (44 14)' )),
(11, QSYS2.ST_WKTTOSQL('point (24 13)' )),
(12, QSYS2.ST_WKTTOSQL('polygon ((50 20, 50 40, 70 30, 50 20))'));
SELECT id, CAST(QSYS2.ST_ASTEXT(geometry) AS VARCHAR(120) ) geometries
FROM sample_geometries;
Results:
ID GEOMETRIES
----- -----------------------------------------------------
10 POINT (44.0 14.0)
11 POINT (24.0 13.0)
12 POLYGON ((50.0 20.0, 70.0 30.0, 50.0 40.0, 50.0 20.0))