ST_WKBToSQL は、事前割り当てバイナリー表現で示された ST_Geometry 値を構成します。 SRID 値 0 が自動的に使用されます。
構文
db2gse.ST_WKBToSQL(WKBGeometry Blob(1M))
戻りタイプ
db2gse.ST_Geometry
例
以下の CREATE TABLE ステートメントは LOTS 表を作成します。この表には 2 つの列があります。LOT_ID 列はそれぞれの敷地を一意的に識別し、 LOT 複数ポリゴン列にはそれぞれの敷地の図形が含まれています。
CREATE TABLE lots (lot_id integer, lot db2gse.ST_MultiPolygon);
以下の C コード断片には、 LOTS 表にデータを挿入する ODBC 関数 (地理情報エクステンダーの SQL 関数に組み込まれている) が含まれています。
ST_WKBToSQL 関数は、WKB 表現を地理情報エクステンダーの図形に変換します。 INSERT ステートメント全体は wkb_sql char string に複写されます。 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);