Use the ST_Shape transform group to transmit
data by using the ESRI shape representation.
When binding out a value from the database to a client application, the same
function provided by ST_AsShape() is used to convert a geometry to its shape representation. When
transferring the shape representation of a geometry to the database, the ST_Geometry(BLOB) function
is used implicitly to perform the conversions to an ST_Geometry value. Using the transform group for
binding in values causes the geometries to be represented in the spatial reference system with the
numeric identifier 0 (zero).
Examples
In the following examples, the
lines of results have been reformatted for readability. The spacing
in your results might vary according to your online display.
- Example 1
The following SQL script shows how the ST_Shape transform group
can be used to retrieve a geometry in its shape representation without
using the explicit ST_AsShape function.
CREATE TABLE transforms_sample(
id INTEGER,
geom db2gse.ST_Geometry)
INSERT
INTO transforms_sample
VALUES ( 1, db2gse.ST_Point(20.0, 30.0, 0) )
SET CURRENT DEFAULT TRANSFORM GROUP = ST_Shape
SELECT id, geom
FROM transforms_sample
WHERE id = 1
Results:
ID GEOM
---- ---------------------------------------------
1 x'0100000000000000000034400000000000003E40'
- Example 2
The following C code shows how to use the ST_Shape transform
group to insert geometries using the explicit ST_Geometry function
for the host-variable
shape_buffer
, which is of type
BLOB and contains the shape representation of a geometry that is to
be inserted.
EXEC SQL BEGIN DECLARE SECTION;
sqlint32 id = 0;
SQL TYPE IS db2gse.ST_Geometry AS BLOB(1000) shape_buffer;
EXEC SQL END DECLARE SECTION;
// set the transform group for all subsequent SQL statements
EXEC SQL
SET CURRENT DEFAULT TRANSFORM GROUP = ST_Shape;
// initialize host variables
...
SET CURRENT DEFAULT TRANSFORM GROUP = ST_Shape;
// insert geometry using shape representation
// into column of type ST_Geometry
EXEC SQL
INSERT
INTO transforms_sample(id, geom)
VALUES ( :id, :shape_buffer );