The ST_AsText() function
The ST_AsText() function takes an ST_Geometry object and returns its well-known text representation.
The return type of ST_AsText() is defined as ST_Geometry to allow spatial objects greater than 2 kilobytes to be retrieved by a client application.
Typically, you use ST_AsText() to
retrieve spatial data from the server and send it to a client, as
in:
SELECT ST_AsText(geomcol) FROM mytable
HCL OneDB™ automatically casts the output of the ST_AsText() function to the proper data type for transmission to the client.
You can
write user-defined routines (UDRs) in C or SPL to extend the functionality
of the existing spatial data type functions. You can use ST_AsText() to
convert an ST_Geometry to its well-known text representation. If you
pass the output of ST_AsText() to another UDR whose
function signature requires an LVARCHAR input, you should explicitly
cast the return type of ST_AsText() to LVARCHAR,
as in:
EXECUTE FUNCTION MySpatialFunc(ST_AsText(geomcol)::lvarchar)
Syntax
ST_AsText(g1 ST_Geometry)
Return type
ST_Geometry
Example
The ST_AsText() function
converts the hazardous_sites location point into its text description:
CREATE TABLE hazardous_sites (site_id integer,
name varchar(40),
location ST_Point);
INSERT INTO hazardous_sites VALUES(
102, 'W. H. Kleenare Chemical Repository',
ST_PointFromText('point (1020.12 324.02)',1000)
);
SELECT site_id, name, ST_AsText(location) Location
FROM hazardous_sites;
site_id 102
name W. H. Kleenare Chemical Repository
location POINT (1020.12 324.02)