ST_create_srs

Use this stored procedure to create a spatial reference system. The ST_create_srs stored procedure takes the conversion factors (offsets and scale factors) as input parameters.

A spatial reference system is defined by the coordinate system, the precision, and the extents of coordinates that are represented in this spatial reference system. The extents are the minimum and maximum possible coordinate values for the X, Y, Z, and M coordinates.

This stored procedure has two variations. This variation takes the conversion factors (offsets and scale factors) as input parameters. The second variation, the ST_create_srs_2 stored procedure, takes the extents and the precision as input parameters and calculates the conversion factors internally.

Authorization

The user ID under which the stored procedure is invoked must have the following authorities or privileges:
  • SYSADM or DBADM authority
  • INSERT and SELECT privileges on the catalog table or view

Syntax

Read syntax diagramSkip visual syntax diagramsysproc.ST_create_srs(srs_name,srs_id,x_offsetnull,x_scale,y_offsetnull,y_scalenull,z_offsetnull,z_scalenull,m_offsetnull,m_scalenull,coordsys_name,descriptionnull,msg_code,msg_text)

Parameter descriptions

srs_name
Identifies the spatial reference system. You must specify a non-null value for this parameter.

The srs_name value is converted to uppercase unless you enclose it in double quotation marks.

The data type of this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).

srs_id
Uniquely identifies the spatial reference system. This numeric identifier is used as an input parameter for various spatial functions. You must specify a non-null value for this parameter.

The data type of this parameter is INTEGER.

x_offset
Specifies the offset for all X coordinates of geometries that are represented in this spatial reference system. The offset is subtracted before the scale factor x_scale is applied when geometries are converted from external representations (WKT, WKB, shape) to the IBM® Spatial Support for Db2 for z/OS® internal representation. (WKT is well-known text, and WKB is well-known binary.) Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 0 (zero) is used.

The data type of this parameter is DOUBLE.

x_scale
Specifies the scale factor for all X coordinates of geometries that are represented in this spatial reference system. The scale factor is applied (multiplication) after the offset x_offset is subtracted when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. You must specify a non-null value for this parameter.

The data type of this parameter is DOUBLE.

y_offset
Specifies the offset for all Y coordinates of geometries that are represented in this spatial reference system. The offset is subtracted before the scale factor y_scale is applied when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is the null value, a value of 0 (zero) is used.

The data type of this parameter is DOUBLE.

y_scale
Specifies the scale factor for all Y coordinates of geometries that are represented in this spatial reference system. The scale factor is applied (multiplication) after the offset y_offset is subtracted when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is null, the value of the x_scale parameter is used. If you specify a value other than null for this parameter, the value that you specify must match the value of the x_scale parameter.

The data type of this parameter is DOUBLE.

z_offset
Specifies the offset for all Z coordinates of geometries that are represented in this spatial reference system. The offset is subtracted before the scale factor z_scale is applied when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 0 (zero) is used.

The data type of this parameter is DOUBLE.

z_scale
Specifies the scale factor for all Z coordinates of geometries that are represented in this spatial reference system. The scale factor is applied (multiplication) after the offset z_offset is subtracted when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 1 is used.

The data type of this parameter is DOUBLE.

m_offset
Specifies the offset for all M coordinates of geometries that are represented in this spatial reference system. The offset is subtracted before the scale factor m_scale is applied when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 0 (zero) is used.

The data type of this parameter is DOUBLE.

m_scale
Specifies the scale factor for all M coordinates of geometries that are represented in this spatial reference system. The scale factor is applied (multiplication) after the offset m_offset is subtracted when geometries are converted from external representations (WKT, WKB, shape) to the IBM Spatial Support for Db2 for z/OS internal representation. Although you must specify a value for this parameter, the value can be null. If this parameter is null, a value of 1 is used.

The data type of this parameter is DOUBLE.

coordsys_name
Uniquely identifies the coordinate system on which this spatial reference system is based. The coordinate system must be listed in the view ST_COORDINATE_SYSTEMS. You must supply a non-null value for this parameter.

Specify the coordsys_name value in uppercase letters.

The data type of this parameter is VARCHAR(130).

description
Describes the spatial reference system by explaining the application's purpose. Although you must specify a value for this parameter, the value can be null. If this parameter is null, no description information is recorded.

The data type of this parameter is VARCHAR(256).

Output parameters

msg_code
Specifies the message code that is returned from the stored procedure. The value of this output parameter identifies the error, success, or warning condition that was encountered during the processing of the procedure. If this parameter value is for a success or warning condition, the procedure finished its task. If the parameter value is for an error condition, no changes to the database were performed.

The data type of this output parameter is INTEGER.

msg_text
Specifies the actual message text, associated with the message code, that is returned from the stored procedure. The message text can include additional information about the success, warning, or error condition, such as where an error was encountered.

The data type of this output parameter is VARCHAR(4096).

When the message code that is returned is 0 (zero), the message text parameter is set to null.

Example

This example shows how to use a Db2 CALL statement to invoke the ST_create_srs stored procedure. This example uses a Db2 CALL statement to create a spatial reference system named SRSDEMO with the following parameter values:
  • srs_id: 1000000
  • x_offset: -180
  • x_scale: 1000000
  • y_offset: -90
  • y_scale: 1000000

call sysproc.ST_create_srs('SRSDEMO',1000000,
                     -180,1000000, -90, 1000000,
                     0, 1, 0, 1,'NORTH_AMERICAN',
                     'SRS for GSE Demo Program: customer table',?,?)

The two question marks at the end of this CALL statement represent the output parameters, msg_code and msg_text. The values for these output parameters are returned after the stored procedure is called.