Use the ST_GML transform group to transmit
data by using the geography markup language (GML).
When binding out a value from the database to a client application, the same
function provided by ST_AsGML() is used to convert a geometry to its GML representation. When the
GML representation of a geometry is transferred to the database, the ST_Geometry(CLOB) 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_GML transform group
can be used to retrieve a geometry in its GML representation without
using the explicit ST_AsGML function.
CREATE TABLE transforms_sample (
id INTEGER,
geom db2gse.ST_Geometry)
INSERT
INTO transforms_sample
VALUES ( 1, db2gse.ST_Geometry('multipoint z (10 10
3, 20 20 4, 15 20 30)', 0) )
SET CURRENT DEFAULT TRANSFORM GROUP = ST_GML
SELECT id, geom
FROM transforms_sample
WHERE id = 1
Results:
ID GEOM
----- -------------------------------------------------------------
1 <gml:MultiPoint srsName=UNSPECIFIED><gml:PointMember>
<gml:Point><gml:coord><gml:X>10</gml:X>
<gml:Y>10</gml:Y><gml:Z>3</gml:Z>
</gml:coord></gml:Point></gml:PointMember>
<gml:PointMember><gml:Point><gml:coord>
<gml:X>20</gml:X><gml:Y>20</gml:Y>
<gml:Z>4</gml:Z></gml:coord></gml:Point>
</gml:PointMember><gml:PointMember><gml:Point>
<gml:coord><gml:X>15</gml:X><gml:Y>20
</gml:Y><gml:Z>30</gml:Z></gml:coord>
</gml:Point></gml:PointMember></gml:MultiPoint>
- Example 2
The following C code shows how to use the ST_GML transform
group for inserting geometries without using the explicit ST_Geometry
function for the host-variable
gml_buffer
, which
is of type CLOB and contains the GML representation of the point (20
,20) that is to be inserted.
EXEC SQL BEGIN DECLARE SECTION;
sqlint32 id = 0;
SQL TYPE IS db2gse.ST_Geometry AS CLOB(1000) gml_buffer;
EXEC SQL END DECLARE SECTION;
// set the transform group for all subsequent SQL statements
EXEC SQL
SET CURRENT DEFAULT TRANSFORM GROUP = ST_GML;
id = 100;
strcpy(gml_buffer.data, "<gml:point><gml:coord>"
"<gml:X>20</gml:X> <gml:Y>20</gml:Y></gml:coord></gml:point>");
//initialize host variables
wkt_buffer.length = strlen(gml_buffer.data);
// insert point using WKT into column of type ST_Geometry
EXEC SQL
INSERT
INTO transforms_sample(id, geom)
VALUES ( :id, :gml_buffer );