The ST_PointFromWKB() function

The ST_PointFromWKB() function takes a well-known binary representation of type ST_Point and a spatial reference ID to return an ST_Point.

Syntax

ST_PointFromWKB (WKB lvarchar, SRID integer)

Return type

ST_Point

Example

The hazardous sites are stored in the hazardous_sites table created with the CREATE TABLE statement that follows. The location column, defined as an ST_Point, stores a location that is the geographic center of each hazardous site:
CREATE TABLE hazardous_sites (site_id   integer,
                              name      varchar(40),
                              location  ST_Point);
The program fragment populates the hazardous_sites table:
    /* Create the SQL insert statement to populate the hazardous_sites
     * table. The question marks are parameter markers that indicate
     * the column values that will be inserted at run time. */
    sprintf(sql_stmt,
            "INSERT INTO hazardous_sites (site_id, name, location) "
            "VALUES(?, ?, ST_PointFromWKB(?, %d))", srid);

    /* Prepare the SQL statement for execution. */
    rc = SQLPrepare (hstmt, (unsigned char *)sql_stmt, SQL_NTS);

    /* Bind the site_id to the first parameter. */
    pcbvalue1 = 0;
    rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
                           SQL_INTEGER, 0, 0,
                           &site_id, 0, &pcbvalue1);

    /* Bind the name to the second parameter. */
    pcbvalue2 = name_len;
    rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR,
                           SQL_CHAR, 0, 0,
                           name, 0, &pcbvalue2);

    /* Bind the location geometry to the third parameter. */
    pcbvalue3 = location_wkb_len;
    rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
                           SQL_INFX_UDT_LVARCHAR, location_wkb_len, 0,
                           location_wkb_buf, location_wkb_len, &pcbvalue3);

    /* Execute the insert statement. */
    rc = SQLExecute (hstmt);