ST_WKBToSQL konstruiert einen Wert ST_Geometry anhand der bekannten binären Darstellung. Der SRID-Wert Null wird automatisch verwendet.
Syntax
db2gse.ST_WKBToSQL(WKBGeometry Blob(1M))
Rückgabetyp
db2gse.ST_Geometry
Beispiele
Die folgende Anweisung CREATE TABLE erstellt die Tabelle LOTS mit zwei Spalten: Die Spalte LOT_ID, die jedes Grundstück eindeutig kennzeichnet, und die Multipolygonspalte LOT, die die Geometrie jedes Grundstücks enthält.
CREATE TABLE lots (lot_id integer, lot db2gse.ST_MultiPolygon);
Der folgende C-Codeausschnitt enthält ODBC-Funktionen, die in SQL-Funktionen des DB2 Spatial Extender eingebettet sind; diese Funktionen fügen Daten in die Tabelle LOTS ein.
Die Funktion ST_WKBToSQL wandelt WKB-Darstellungen in DB2 Spatial Extender-Geometrien um. Die gesamte Anweisung INSERT wird in eine Zeichenfolge wkb_sql kopiert. Die Anweisung INSERT enthält Parametermarken zum dynamischen Akzeptieren der LOT_ID-Daten und der LOT-Daten.
/* 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);