sqle_deactivate_db API - Deactivate database

Deactivates the specified database and stops all associated database services.

Scope

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.

Note: If an error is encountered then the database may remain activated on those members where the API failed.

Authorization

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

Required connection

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

API include file

sqlenv.h

API and data structure syntax

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;

db2DeactivateDb API parameters

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

db2DeactivateDbStruct 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. Pre-defined value which is used explicitly to force the deactivation of the database and to denote that the deactivate command is being issued in the content of a specified list of members.
iNumMembers
Input. Number of members listed in iMemberList.
piMemberList
Input. Pointer to the member list.

sqle_deactivate_db API parameters

pDbAlias
Input. Pointer to the database alias name.
pUserName
Input. Pointer to the user ID stopping 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_deactivate_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 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 );
  • Deactivate a database globally across all members
       deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_GLOBAL;
       deactivateDbStruct->piMemberList = NULL;
    
  • Deactivate a database at a member
       deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_MEMBER;
       deactivateDbStruct->piMemberList->numMembers = 1;
       deactivateDbStruct->piMemberList->pMember[0] = 20;
  • Deactivate a database at a specific member 30, using the FORCE option
       deactivateDbStruct.iOptions = DB2_ACTDEACT_DB_MEMBER;
       deactivateDbStruct.iOptions |= DB2_DEACTIVATE_FORCE;
       deactivateDbStruct->piMemberList->numMembers = 1;
       deactivateDbStruct->piMemberList->pMember[0] = 30;

Usage notes

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.

REXX API syntax

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