ST_WKBToSQL crée une valeur ST_Geometry à partir de sa représentation WKB. La valeur SRID 0 est automatiquement utilisée.
Syntaxe
db2gse.ST_WKBToSQL(WKBGeometry Blob(1M))
Type de retour
db2gse.ST_Geometry
Exemples
L'instruction CREATE TABLE ci-après crée la table LOTS avec les deux colonnes suivantes : la colonne LOT_ID qui identifie chaque parcelle de façon univoque et la colonne des multipolygones LOT, qui contient la géométrie de chaque parcelle.
CREATE TABLE lots (lot_id integer, lot db2gse.ST_MultiPolygon);
Le fragment de code C présenté ci-dessous contient des fonctions ODBC imbriquées dans des fonctions SQL Extension Spatiale qui insèrent des données dans la table LOTS.
La fonction ST_WKBToSQL convertit les représentations WKB en géométrie Extension Spatiale. La totalité de l'instruction INSERT est copiée dans une chaîne de caractères de type wkb_sql. L'instruction INSERT contient des marqueurs de paramètre permettant d'accepter dynamiquement les données LOT_ID et 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);