ST_WKBToSQL
ST_WKBToSQL takes a well-known binary representation of a geometry and returns the corresponding geometry. The spatial reference system with the identifier 0 (zero) is used for the resulting geometry.
If the given well-known binary representation is null, null is returned.
Syntax
Parameter
- wkb
- A value of type BLOB(4M) that contains the well-known binary representation of the resulting geometry. If the well-known binary representation is null, null is returned.
Return type
db2gse.ST_Geometry
Example
This example illustrates use of
the ST_WKBToSQL function. First, geometries are stored in the SAMPLE_GEOMETRIES
table in its GEOMETRY column. Then, their well-known binary representations
are stored in the WKB column using the ST_AsBinary function in the
UPDATE statement. Finally, the ST_WKBToSQL function is used to return
the coordinates of the geometries in the WKB column.
SET CURRENT PATH = CURRENT PATH, db2gse
CREATE TABLE sample_geometries
(id INTEGER, geometry ST_Geometry, wkb BLOB(32K) )
INSERT INTO sample_geometries (id, geometry)
VALUES (10, ST_Point ( 'point (44 14)', 0 ) ),
(11, ST_Point ( 'point (24 13)', 0 ) ),
(12, ST_Polygon ('polygon ((50 20, 50 40, 70 30, 50 20))', 0 ) )
UPDATE sample_geometries AS temp_correlated
SET wkb = ST_AsBinary(geometry)
WHERE id = temp_correlated.id
Use this SELECT statement to see the geometries in the
WKB column.
SELECT id, CAST( ST_AsText( ST_WKBToSQL(wkb) ) AS VARCHAR(120) ) GEOMETRIES
FROM sample_geometries
Results:
ID GEOMETRIES
----------- -------------------------------------------------------------
10 POINT ( 44.00000000 14.00000000)
11 POINT ( 24.00000000 13.00000000)
12 POLYGON (( 50.00000000 20.00000000, 70.00000000 30.00000000,
50.00000000 40.00000000, 50.00000000 20.00000000))
