The SE_MLineFromShape() function

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

Syntax

SE_MLineFromShape(s1 lvarchar, SRID integer)

Return type

ST_MultiLineString

Example

The waterways table is created with the ID and name columns that identify each stream and river system stored in the table. The water column is an ST_MultiLineString because the river and stream systems are often an aggregate of several linestrings:
CREATE TABLE waterways (id     integer,
                        name   varchar(128),
                        water  ST_MultiLineString);
This code fragment populates the waterways table with a unique ID, a name, and a water multilinestring:
/* Create the SQL insert statement to populate the waterways
     * table. The question marks are parameter markers that indicate
     * the column values that will be inserted at run time. */
    sprintf(sql_stmt,
            "INSERT INTO waterways (id,name,water) "
            "VALUES(?, ?, ST_MlineFromShape(?, %d))", srid);

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

    /* Bind the id to the first parameter. */
    pcbvalue1 = 0;
    rc = SQLBindParameter (hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG,
                           SQL_INTEGER, 0, 0,
                           &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, name_len, 0,
                           name, name_len, &pcbvalue2);

    /* Bind the water geometry to the third parameter. */
    pcbvalue3 = water_shape_len;
    rc = SQLBindParameter (hstmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY,
                           SQL_INFX_UDT_LVARCHAR, water_shape_len, 0,
                           water_shape_buf, water_shape_len, &pcbvalue3);
    /* Execute the insert statement. */
    rc = SQLExecute (hstmt);