ST_InteriorRingN

ST_InteriorRingN takes a polygon and an index as input parameters and returns the interior ring identified by the given index as a linestring. The interior rings are organized according to the rules defined by the internal geometry verification routines.

If the given polygon is null or is empty, or if it does not have any interior rings, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_InteriorRingN(polygon,index )

Parameter

polygon
A value of type ST_Polygon that represents the geometry from which the interior ring identified by index is returned.
index
A value of type INTEGER that identifies the nth interior ring that is returned. If there is no interior ring identified by index, then a warning is returned (01HS1).

Return type

db2gse.ST_LineString

Example

In this example, a polygon is created with two interior rings. The ST_InteriorRingN call is then used to retrieve the second interior ring.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_polys (id INTEGER, geometry ST_Polygon)

INSERT INTO sample_polys VALUES
       (1, ST_Polygon('polygon((40 120, 90 120, 90 150, 40 150, 40 120),
                     (50 130, 60 130, 60 140, 50 140, 50 130),
                     (70 130, 80 130, 80 140, 70 140, 70 130))' ,0))


SELECT id, CAST(ST_AsText(ST_InteriorRingN(geometry, 2)) as VARCHAR(180))  
       Interior_Ring
FROM sample_polys

Results:

ID          INTERIOR_RING
----------- ------------------------------------------------------------------
  				1 LINESTRING ( 70.00000000 130.00000000, 70.00000000 140.00000000, 
80.00000000 140.00000000, 80.00000000 130.00000000, 70.00000000 130.00000000)