ST_AsGML

ST_AsGML takes a geometry as an input parameter and returns its representation using the Geography Markup Language (GML).

If the given geometry is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_AsGML(geometry ,gmlLevel ,orgName,orgID )

Parameter

geometry
A value of one of the seven distinct spatial data types that represents the geometry that is to be converted to the corresponding GML representation.
gmlLevel
Specifies an integer that represents the GML level that is being used. The supported values are 2 and 3.
orgName
Specifies the organization name for the coordinate system that is being used.
orgID
Specifies the organization ID for the coordinate system that is being used.

Return type

CLOB(8M)

Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display.

The following code fragment illustrates how to use the ST_AsGML function to view the GML fragment. This example populates the GML column, from the geometry column, with an ID of 2222.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE SAMPLE_POINTS (id integer, geometry ST_POINT, gml CLOB(32K))

INSERT INTO SAMPLE_POINTS (id, geometry)
VALUES
    (1100, ST_Point(10, 20, 1))

INSERT INTO sample_points(id, gml)
VALUES (2222,
  (SELECT  ST_AsGML(geometry, 'EPSG', 4269)
   FROM    sample_points
   WHERE   id = 1100))

The following SELECT statement lists the ID and the GML representation of the geometries. The geometry is converted to a GML fragment by the ST_AsGML function.

SELECT id, cast(ST_AsGML(geometry, 'EPSG', 4269) 
AS varchar(110)) AS gml_fragment
FROM   sample_points
WHERE  id = 1100

Results:

The SELECT statement returns the following result set:

ID          GML_FRAGMENT

----------- ------------------------------------------------------------
       1100 <gml:Point srsName="EPSG:4269"><gml:coord>
            <gml:X>10</gml:X><gml:Y>20</gml:Y> 
            </gml:coord></gml:Point>