The ST_LineFromWKB() function
The ST_LineFromWKB() function takes a well-known binary representation of type ST_LineString and a spatial reference ID, returning an ST_LineString.
Syntax
ST_LineFromWKB(wkb lvarchar, SRID integer)
Return type
ST_LineString
Example
The sewerlines table is created
with three columns. The first column, sewer_id, uniquely identifies
each sewer line. The INTEGER class column identifies the type
of sewer line, generally associated with the line capacity. The sewer ST_LineString column
stores the sewer line geometries:
CREATE TABLE sewerlines (sewer_id integer,
class integer,
sewer ST_LineString);
This
code fragment populates the sewerlines table with the unique
ID, class, and geometry of each sewer line:
/* Create the SQL insert statement to populate the sewerlines
* table. The question marks are parameter markers that indicate
* the column values that will be inserted at run time. */
sprintf(sql_stmt,
"INSERT INTO sewerlines (sewer_id,class,sewer) "
"VALUES(?, ?, ST_LineFromWKB(?, %d))", srid);
/* Prepare the SQL statement for execution. */
rc = SQLPrepare (hstmt, (unsigned char *)sql_stmt, SQL_NTS);
/* Bind the sewer_id to the first parameter. */
pcbvalue1 = 0;
rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0,
&sewer_id, 0, &pcbvalue1);
/* Bind the sewer_class to the second parameter. */
pcbvalue2 = 0;
rc = SQLBindParameter (hstmt, 2, SQL_PARAM_INPUT, SQL_C_SLONG,
SQL_INTEGER, 0, 0,
&sewer_class, 0, &pcbvalue2);
/* Bind the sewer geometry to the third parameter. */
pcbvalue3 = sewer_wkb_len;
rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
SQL_INFX_UDT_LVARCHAR, sewer_wkb_len, 0,
sewer_wkb_buf, sewer_wkb_len, &pcbvalue3);
/* Execute the insert statement. */
rc = SQLExecute (hstmt);