IBM Books

API Reference

sqlerstd - Restart Database

Restarts a database that has been abnormally terminated and left in an inconsistent state. At the successful completion of RESTART DATABASE, the application remains connected to the database if the user has CONNECT privilege.

Scope

This API affects only the node on which it is executed.

Authorization

None

Required Connection

This API establishes a database connection.

API Include File

sqlenv.h

C API Syntax



/* File: sqlenv.h */
/* API: Restart Database */
/* ... */
SQL_API_RC SQL_API_FN
  sqlerstd (
    _SQLOLDCHAR * pDbAlias,
    _SQLOLDCHAR * pUserName,
    _SQLOLDCHAR * pPassword,
    struct sqlca * pSqlca);
/* ... */

Generic API Syntax



/* File: sqlenv.h */
/* API: Restart Database */
/* ... */
SQL_API_RC SQL_API_FN
  sqlgrstd (
    unsigned short PasswordLen,
    unsigned short UserNameLen,
    unsigned short DbAliasLen,
    struct sqlca * pSqlca,
    _SQLOLDCHAR * pPassword,
    _SQLOLDCHAR * pUserName,
    _SQLOLDCHAR * pDbAlias);
/* ... */

API Parameters

PasswordLen
Input. A 2-byte unsigned integer representing the length in bytes of the password. Set to zero if no password is supplied.
UserNameLen
Input. A 2-byte unsigned integer representing the length in bytes of the user name. Set to zero if no user name is supplied.
DbAliasLen
Input. A 2-byte unsigned integer representing the length in bytes of the database alias.
pSqlca
Output. A pointer to the sqlca structure. For more information about this structure, see SQLCA.
pPassword
Input. A string containing the password of the supplied user name (if any). May be NULL.
pUserName
Input. A string containing the user name of the application. May be NULL.
pDbAlias
Input. A string containing the alias of the database that is to be restarted.

REXX API Syntax



RESTART DATABASE database_alias [USER username USING password]

REXX API Parameters

database_alias
Alias of the database to be restarted.
username
User name under which the database is to be restarted.
password
Password used to authenticate the user name.

Sample Programs

C
\sqllib\samples\c\restart.c

COBOL
\sqllib\samples\cobol\restart.cbl

FORTRAN
\sqllib\samples\fortran\restart.f

REXX
\sqllib\samples\rexx\restart.cmd

Usage Notes

Call this API if an attempt to connect to a database returns an error message, indicating that the database must be restarted. This action occurs only if the previous session with this database terminated abnormally (due to power failure, for example).

At the completion of this API, a shared connection to the database is maintained if the user has CONNECT privilege, and an SQL warning is issued if any indoubt transactions exist. In this case, the database is still usable, but if the indoubt transactions are not resolved before the last connection to the database is dropped, another RESTART DATABASE must be issued before the database can be used again. Use the transaction APIs (see Appendix B. "Transaction APIs") to generate a list of indoubt transactions. For more information about indoubt transactions, see the Administration Guide.

If the database is only restarted on a single node within an MPP system, a message may be returned on a subsequent database query indicating that the database needs to be restarted. This occurs because the database on a node on which the query depends must also be restarted. Restarting the database on all nodes solves the problem.

See Also

CONNECT TO statement in the SQL Reference.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]