The SE_LineFromShape() function

The SE_LineFromShape() function takes a shape of type polyline and a spatial reference ID to return an ST_LineString. A polyline with only one part is appropriate as an ST_LineString, and a polyline with multiple parts is appropriate as an ST_MultiLineString (see The SE_MLineFromShape() function).

Syntax

SE_LineFromShape(s1 lvarchar, SRID integer)

Return type

ST_LineString

Example

The sewerlines table is created with three columns: sewer_id, which uniquely identifies each sewer line; the INTEGER class column, which identifies the type of sewer line (generally associated with the line's capacity); and the sewer ST_LineString column, which stores the sewer line geometry:
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(?, ?, SE_LineFromShape(?, %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_shape_len;
    rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
                           SQL_INFX_UDT_LVARCHAR, sewer_shape_len, 0,
                           sewer_shape_buf, sewer_shape_len, &pcbvalue3);

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