ST_ASBINARY scalar function

The ST_ASBINARY function takes a geometry object as an input parameter and returns a BLOB containing the corresponding well-known binary (WKB) format.

If geometry is null, the result is the null value. There is no WKB representation for an empty geometry. If geometry is empty, an error is returned.

Read syntax diagramSkip visual syntax diagramST_ASBINARY(geometry)
geometry
A value of type ST_GEOMETRY or one of its subtypes to be converted to the corresponding WKB format.

The result of the function is BLOB(2G).

Example

Insert the WKB value of a point into a table. Return its value in WKT format.

CREATE TABLE sample_points(id INTEGER, wkb BLOB(32K));

INSERT INTO sample_points values (10, QSYS2.ST_ASBINARY(QSYS2.ST_POINT(10, 20)));

SELECT id, QSYS2.ST_ASTEXT(QSYS2.ST_POINT(wkb)) as point, wkb FROM sample_points;

Results:


ID     POINT                WKB
----   -------------------  --------------------------------------------
  10   POINT (10.0 20.0)    000000000140240000000000004034000000000000