Deactivates the specified database and stops all associated database services.
This API deactivates the specified database on all members. If one or more of these members encounters an error during deactivation of the database, a warning is returned. The database will be deactivated on all members where the API executed successfully.
None. Applications invoking DEACTIVATE DATABASE cannot have any existing database connections.
sqlenv.h
SQL_API_RC SQL_API_FN
db2DeactivateDb(
db2Uint32 versionNumber,
void * pDB2DeactivateDbStruct,
struct sqlca * pSqlca);
typedef SQL_STRUCTURE db2DeactivateDbStruct
{
char * piDbAlias;
char * piUserName;
char * piPassword;
db2Uint32 iOptions;
db2Uint32 iNumMembers;
SQL_PDB_NODE_TYPE * piMemberList;
} db2DeactivateDbStruct;
This section provides examples of different database deactivation scenarios. The following code block is a common body program that will be used for the database deactivation scenarios.
struct sqlca sqlca; // sqlca to carry the sqlcode
struct db2DeactivateDbStruct deactivateDbStruct;
strcpy(deactivateDbStruct->piUserName, "USER1"); //local instance
The following deactivate API is shown common to the scenarios listed in the following examples:
db2DectivateDb( db2Version, &deactivateDbStruct, &sqlca );
deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_GLOBAL;
deactivateDbStruct->piMemberList = NULL;
deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_MEMBER;
deactivateDbStruct->piMemberList->numMembers = 1;
deactivateDbStruct->piMemberList->pMember[0] = 20;
deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_MEMBER;
deactivateDbStruct.iOptions |= DB2_DEACTIVATE_FORCE;
deactivateDbStruct->piMemberList->numMembers = 1;
deactivateDbStruct->piMemberList->pMember[0] = 30;
Databases initialized by ACTIVATE DATABASE can only be shut down by DEACTIVATE DATABASE. db2InstanceStop automatically stops all activated databases before stopping the database manager. If a database was initialized by ACTIVATE DATABASE, the last user application to disconnect will not shut the database down; DEACTIVATE DATABASE must be used in that case too.
This API can be called from REXX through the SQLDB2 interface.