用户指南和参考

ShapeToSQL

ShapeToSQL 构造一个 db2gse.ST_Geometry 值,给出它的公认二进制表示。 自动使用值为 0 的 SRID。

语法

db2gse.ST_ShapeToSQL(ShapeGeometry blob(1M))

返回类型

db2gse.ST_Geometry

示例

以下 C 代码段包含 ODBC 函数,这些函数嵌有将数据插入 LOTS 表的 DB2 Spatial Extender SQL 函数。 已创建了 LOTS 表,该表具有两列:lot_id 列和地块复合多边形列,前者唯一标识每个地块, 后者包含每个地块的几何图形。

CREATE TABLE lots (lot_id  integer,
                   lot     db2gse.ST_MultiPolygon);

ShapeToSQL 函数将形状转换为 DB2 Spatial Extender 几何图形。 将整个 INSERT 语句复制到 shp_sql。该 INSERT 语句包含一些参数标记, 以动态接受 LOT_id 和地块数据。

/* Create the SQL insert statement to populate the lot id and the
   lot multipolygon. The question marks are parameter markers that
   indicate the lot_id and lot values that will be retrieved at
   run time. */
 
strcpy (shp_sql,"insert into lots (lot_id, lot) values(?,
db2gse.ShapeToSQL(cast(? as blob(1m))))");
 
/* Allocate memory for the SQL statement handle and associate the
   statement handle with the connection handle. */
 
rc = SQLAllocStmt (handle, &hstmt);
 
/* Prepare the SQL statement for execution. */
 
rc = SQLPrepare (hstmt, (unsigned char *)shp_sql, SQL_NTS);
 
/* Bind the integer key value to the first parameter. */
 
pcbvalue1 = 0;
 
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
     SQL_INTEGER, 0, 0, &lot_id, 0, &pcbvalue1);
 
/* Bind the shape to the second parameter. */
 
pcbvalue2 = blob_len;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_BINARY,
     SQL_BLOB, blob_len, 0, shape_blob, blob_len, &pcbvalue2);
 
/* Execute the insert statement. */
 
rc = SQLExecute (hstmt);


[ 页的顶部 | 上一页 | 下一页 | 目录 | 索引 ]