The SE_AsShape() function
The SE_AsShape() function takes a geometry object and returns it in ESRI shapefile format.
The return type of SE_AsShape() is defined as ST_Geometry to allow spatial objects greater than 2 kilobytes in size to be retrieved by a client application.
Typically,
you use ST_AsShape() to retrieve spatial data from
the server and send it to a client, as in:
SELECT SE_AsShape(geomcol) FROM mytable
HCL OneDB™ automatically casts the output of the SE_AsShape() 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 SE_AsShape() to
convert an ST_Geometry to ESRI shapefile format. If you pass the output
of SE_AsShape() to another UDR whose function signature
requires an LVARCHAR input, you should explicitly cast the return
type of SE_AsShape() to LVARCHAR, as in:
EXECUTE FUNCTION MySpatialFunc(SE_AsShape(geomcol)::lvarchar);
Syntax
SE_AsShape(g1 ST_Geometry)
Return type
ST_Geometry
Example
The code fragment below illustrates
how the SE_AsShape() function converts the zone polygons
of the sensitive_areas table into shape polygons. These shape
polygons are passed to the application's draw_polygon() function
for display:
/* Create the SQL expression. */
sprintf(sql_stmt,
"SELECT SE_AsShape(zone) "
"FROM sensitive_areas WHERE "
"SE_EnvelopesIntersect(zone,SE_PolyFromShape(?,%d))", srid);
/* Prepare the SQL statement. */
SQLPrepare(hstmt, (UCHAR *)sql_stmt, SQL_NTS);
/* Bind the query geometry parameter. */
pcbvalue1 = query_shape_len;
SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_BINARY,
SQL_INFX_UDT_LVARCHAR, query_shape_len, 0,
query_shape_buf, query_shape_len, &pcbvalue1);
/* Execute the query. */
rc = SQLExecute(hstmt);
/* Assign the results of the query (the Zone polygons) to the
fetched_shape_buf variable. */
SQLBindCol (hstmt, 1, SQL_C_BINARY,
fetched_shape_buf, 10000, &fetched_shape_len);
/* Fetch each polygon within the display window and display it. */
while (SQL_SUCCESS == (rc = SQLFetch(hstmt)))
draw_polygon(fetched_shape_buf);