ST_AsShape function
The St_AsShape function takes a geometry as an input parameter and returns its ESRI shape representation.
If the given geometry is null, then null is returned.
This function can also be called as a method.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes to be converted to the corresponding ESRI shape representation.
Return type
BLOB(2G)
Example
The following code fragment illustrates
how to use the ST_AsShape function to convert the points in the geometry
column of the SAMPLE_POINTS table into shape binary representation
in the shape BLOB column. This example populates the shape column
from the geometry column. The shape binary representation is used
to display the geometries in geobrowsers, which require geometries
to comply with the ESRI shapefile format, or to construct the geometries
for the *.SHP file of the shape file.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE SAMPLE_POINTS (id integer, geometry ST_POINT, shape BLOB(32K))
INSERT INTO SAMPLE_POINTS (id, geometry)
VALUES
(1100, ST_Point(10, 20, 1))
INSERT INTO sample_points(id, shape)
VALUES (2222,
(SELECT ST_AsShape(geometry)
FROM sample_points
WHERE id = 1100))
SELECT id, substr(ST_AsShape(geometry), 1, 20) AS shape
FROM sample_points
WHERE id = 1100
Returns:
ID SHAPE
------ -------------------------------------------
1100 x'0100000000000000000024400000000000003440'