# ST_ToMultiLine function

The ST_ToMultiLine function takes a geometry as an input parameter and converts it to a multilinestring. The resulting multilinestring is represented in the spatial reference system of the given geometry.

The given geometry must be empty, a multilinestring, or a linestring. If the given geometry is null, then null is returned.

This function can also be called as a method.

## Syntax

## Parameter

- geometry
- A value of type ST_Geometry or one of its subtypes that represents
the geometry that is converted to a multilinestring.
A geometry can be converted to a multilinestring if it is empty, a linestring, or a multilinestring. If the conversion cannot be performed, then an exception condition is raised (SQLSTATE 38SUD).

## Return type

db2gse.ST_MultiLineString

## Example

In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display

This example
illustrates the use of the ST_ToMultiLine function.

```
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geometries (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geometries
VALUES (1, ST_Geometry ('multilinestring ((0 10 1, 0 0 3, 10 0 5),
(23 43, 27 34, 35 12))', 0) ),
(2, ST_Geometry ('linestring z (0 10 1, 0 0 3, 10 0 5)', 0) ),
(3, ST_Geometry ('point empty', 1) ),
(4, ST_Geometry ('multipolygon empty', 1) )
```

In the following SELECT statement, the ST_ToMultiLine
function is used to return multilinestrings converted to ST_MultiLineString
from the static type of ST_Geometry. ```
SELECT CAST( ST_AsText( ST_ToMultiLine(geometry) )
AS VARCHAR(130) ) LINES
FROM sample_geometries
```

Results: ```
LINES
------------------------------------------------------
MULTILINESTRING Z ( 0.00000000 10.00000000 1.00000000,
0.00000000 0.00000000 3.00000000,
10.00000000 0.00000000 5.00000000)
MULTILINESTRING EMPTY
MULTILINESTRING EMPTY
```