用户指南和参考

ST_WKBToSQL

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

语法

db2gse.ST_WKBToSQL(WKBGeometry Blob(1M))

返回类型

db2gse.ST_Geometry

示例

以下 CREATE TABLE 语句创建 LOTS 表, 该表具有两列:LOT_ID 列和LOT 复合多边形列,前者唯一地标识每个地块,后者包含每个地块的几何图形。

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

以下 C 代码段包含 ODBC 函数,这些函数嵌有将数据插入 LOTS 表的 DB2 Spatial Extender SQL 函数。

ST_WKBToSQL 函数将 WKB 表示转换为 DB2 Spatial Extender 几何图形。 整个 INSERT 语句被复制到 wkb_sql 字符串。 INSERT 语句包含参数标记以动态接受 LOT_ID 数据和 LOT 数据。

/* 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 (wkb_sql,"insert into lots (lot_id, lot)
  values(?, db2gse.ST_WKBToSQL(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 *)wkb_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);


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