ST_ENABLE_DB procedure

Use this stored procedure to supply a database with the resources that it needs to store spatial data and to support spatial operations. These resources include spatial data types, spatial index types, catalog views, supplied functions, and other stored procedures.

This stored procedure replaces DB2GSE.gse_enable_db.

Authorization

The user ID under which the stored procedure is invoked must have DBADM authority on the database that is being enabled.

Syntax

Read syntax diagramSkip visual syntax diagramDB2GSE.ST_ENABLE_DB(table_creation_parametersnull, msg_code , msg_text )

Parameter descriptions

table_creation_parameters
Specifies any options that are to be added to the CREATE TABLE statements for the Db2® Spatial Extender catalog tables. Although you must specify a value for this parameter, the value can be null. If this parameter is null, no options are added to the CREATE TABLE statements.
To specify these options, use the syntax of the Db2 CREATE TABLE statement. For example, to specify a table space in which to create the tables, use:

IN tsName INDEX IN indexTsName

The data type of this parameter is VARCHAR(32K).

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(1024).

Example

The following example shows how to use the Call Level Interface (CLI) to invoke the ST_ENABLE_DB stored procedure:

SQLHANDLE  henv;
  SQLHANDLE  hdbc;
  SQLHANDLE  hstmt;
  SQLCHAR    uid[MAX_UID_LENGTH + 1];
  SQLCHAR    pwd[MAX_PWD_LENGTH + 1];
  SQLINTEGER ind[3];
  SQLINTEGER msg_code = 0;
  char       msg_text[1024] = "";
  SQLRETURN  rc;
  char       *table_creation_parameters = NULL;

  /* Allocate environment handle */
  rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);

  /* Allocate database handle */
  rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);

  /* Establish a connection to database "testdb" */
  rc = SQLConnect(hdbc, (SQLCHAR *)"testdb", SQL_NTS, (SQLCHAR *)uid,SQL_NTS,
                  (SQLCHAR *)pwd, SQL_NTS);


  /* Allocate statement handle */
  rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt) ;

  /* Associate SQL statement to call the ST_ENABLE_DB stored procedure    */
  /* with statement handle and send the statement to DBMS to be prepared. */
  rc = SQLPrepare(hstmt, "call DB2GSE!ST_ENABLE_DB(?,?,?)", SQL_NTS);

  /* Bind 1st parameter marker in the SQL call statement, the input */
  /* parameter for table creation parameters, to variable           */
  /* table_creation_parameters.                                     */
  ind[0] = SQL_NULL_DATA;
  rc = SQLBindParameter(hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_CHAR,
       SQL_VARCHAR, 255, 0, table_creation_parameters, 256, &ind[0]);

  /* Bind 2nd parameter marker in the SQL call statement, the output */
  /* parameter for returned message code, to variable msg_code.      */
  ind[1] = 0;
  rc = SQLBindParameter(hstmt, 2, SQL_PARAM_OUTPUT, SQL_C_LONG,
                        SQL_INTEGER, 0, 0, &msg_code, 4, &ind[1]);

  /* Bind 3rd parameter marker in the SQL call statement, the output */
  /* parameter returned message text, to variable msg_text.          */
  ind[2] = 0;
  rc = SQLBindParameter(hstmt, 3, SQL_PARAM_OUTPUT, SQL_C_CHAR,
                        SQL_VARCHAR, (sizeof(msg_text)-1), 0, msg_text,
                         sizeof(msg_text), &ind[2]);
  rc = SQLExecute(hstmt);