The ST_MPointFromWKB() function
The ST_MPointFromWKB() function creates an ST_MultiPoint from a well-known binary representation of type ST_MultiPoint and a spatial reference ID.
Syntax
ST_MPointFromWKB (WKB lvarchar, SRID integer)
Return type
ST_MultiPoint
Example
The species_sitings table
is created with three columns. The species and genus columns
uniquely identify each row, while the sitings ST_MultiPoint
stores the locations of the species sightings:
CREATE TABLE species_sitings (species varchar(32),
genus varchar(32),
sitings ST_MultiPoint);
This
code fragment populates the species_sitings table:
/* Create the SQL insert statement to populate the species_sitings
* table. The question marks are parameter markers that indicate
* the column values that will be inserted at run time. */
sprintf(sql_stmt,
"INSERT INTO species_sitings (species,genus,sitings) "
"VALUES(?, ?, ST_MpointFromWKB(?, %d))", srid);
/* Prepare the SQL statement for execution. */
rc = SQLPrepare (hstmt, (unsigned char *)sql_stmt, SQL_NTS);
/* Bind the species to the first parameter. */
pcbvalue1 = species_len;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, species_len, 0,
species, species_len, &pcbvalue1);
/* Bind the genus to the second parameter. */
pcbvalue2 = genus_len;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
SQL_CHAR, genus_len, 0,
genus, genus_len, &pcbvalue2);
/* Bind the sitings geometry to the third parameter. */
pcbvalue3 = sitings_wkb_len;
rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
SQL_INFX_UDT_LVARCHAR, sitings_wkb_len, 0,
sitings_wkb_buf, sitings_wkb_len, &pcbvalue3);
/* Execute the insert statement. */
rc = SQLExecute (hstmt);