DB2 Version 10.1 for Linux, UNIX, and Windows

sqle_activate_db API - Activate database

Activates the specified database and starts up all associated database services, so that the database is available for connection and use by any application.

Scope

This API activates the specified database on all members. If one or more of these members encounters an error during activation of the database, a warning is returned. The database remains activated on all members on which the API has succeeded.
Note: If an error is encountered then the database may remain deactivated on those members where the API failed.

Authorization

One of the following authorities:
  • SYSADM
  • SYSCTRL
  • SYSMAINT

Required connection

None. Applications invoking ACTIVATE DATABASE cannot have any existing database connections.

API include file

sqlenv.h

API and data structure syntax

SQL_API_RC SQL_API_FN
db2ActivateDb (
        db2Uint32 versionNumber,
        void * pDB2ActivateDbStruct,
        struct sqlca * pSqlca);

typedef SQL_STRUCTURE db2ActivateDbStruct
{
        char * piDbAlias;
        char * piUserName;
        char * piPassword;
        db2Uint32 iOptions;
 } db2ActivateDbStruct;

db2ActivateDb API parameters

versionNumber
Input. Specifies the version and release level of the structure passed as the second parameter data.
pDB2ActivateDbStruct
Input. Pointer to the db2ActivateDbStruct structure.
pSqlca
Output. Pointer to the sqlca structure.

db2ActivateDbStruct data structure parameters

piDbAlias
Input. Pointer to the database alias name.
piUserName
Input. Pointer to the user ID starting the database. Can be NULL.
piPassword
Input. Pointer to the password for the user name. Can be NULL, but must be specified if a user name is specified.
iOptions
Input. Reserved for future use.

sqle_activate_db API parameters

pDbAlias
Input. Pointer to the database alias name.
pUserName
Input. Pointer to the user ID starting the database. Can be NULL.
pPassword
Input. Pointer to the password for the user name. Can be NULL, but must be specified if a user name is specified.
pReserved
Reserved for future use.
pSqlca
Output. Pointer to the sqlca structure.

sqlg_activate_db API-specific parameters

DbAliasLen
Input. A 2-byte unsigned integer representing the length of the database alias name in bytes.
UserNameLen
Input. A 2-byte unsigned integer representing the length of the user name in bytes. Set to zero if no user name is supplied.
PasswordLen
Input. A 2-byte unsigned integer representing the length of the password in bytes. Set to zero if no password is supplied.

Examples

This section provides an example of a database activation scenario. The following code block is a common body program that will be used for the database activation scenarios.

        struct sqlca sqlca;             // sqlca to carry the sqlcode
        struct db2ActivateDbStruct activateDbStruct;
        struct db2ActDeactMemberStruct  memberList;
 
        strcpy(activateDbStruct->piUserName, "USER1"); //local instance

The following activate API is shown common to the scenarios listed in the following examples:

        db2ActivateDb( db2Version, &activateDbStruct, &sqlca );

Usage notes

Database administrators can use ACTIVATE DATABASE to start selected databases. This eliminates any application time spent on database initialization.

Databases initialized by ACTIVATE DATABASE can only be shut down by sqle_deactivate_db, or by db2InstanceStop. To obtain a list of activated databases, you may invoke the db2GetSnapshot. API

If a database was started by a DB2 CONNECT TO command (or by an implicit connect), and subsequently an ACTIVATE DATABASE is issued for that same database, then DEACTIVATE DATABASE must also be used to shut down that database.

See the autorestart configuration parameter for database connection behavior when the target database is in an inconsistent state.

REXX API syntax

This API can be called from REXX through the SQLDB2 interface.