OCILIB (C and C++ Driver for Oracle)  4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
Remote Instance startup/shutdown

Detailed Description

OcilibCApiSubscriptions

OCILIB supports Oracle 11g client features for manipulating remote Oracle instances.

Oracle instances (on the same computer or on a remote server) can be :

Several options are handled for this actions

Example
#include "ocilib.h"
void err_handler(OCI_Error *err)
{
printf("%s\n", OCI_ErrorGetString(err));
}
int main(void)
{
OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT);
/* start remote instance */
"sys_usr",
"sys_pwd",
OCI_SESSION_SYSDBA,
OCI_DB_SPM_FULL,
OCI_DB_SPF_FORCE,
NULL);
/* shutdown remote instance */
"sys_usr",
"sys_pwd",
OCI_SESSION_SYSDBA,
OCI_DB_SDM_FULL,
OCI_DB_SDF_ABORT);
return EXIT_SUCCESS;
}
struct OCI_Error OCI_Error
Encapsulates an Oracle or OCILIB exception.
Definition: types.h:390
OCI_SYM_PUBLIC const otext *OCI_API OCI_ErrorGetString(OCI_Error *err)
Retrieve error message from error handle.
OCI_SYM_PUBLIC boolean OCI_API OCI_Cleanup(void)
Clean up all resources allocated by the library.
OCI_SYM_PUBLIC boolean OCI_API OCI_Initialize(POCI_ERROR err_handler, const otext *lib_path, unsigned int mode)
Initialize the library.
OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseShutdown(const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int shut_mode, unsigned int shut_flag)
Shutdown a database instance.
OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseStartup(const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int start_mode, unsigned int start_flag, const otext *spfile)
Start a database instance.

Functions

OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseStartup (const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int start_mode, unsigned int start_flag, const otext *spfile)
 Start a database instance.
 
OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseShutdown (const otext *db, const otext *user, const otext *pwd, unsigned int sess_mode, unsigned int shut_mode, unsigned int shut_flag)
 Shutdown a database instance.
 

Function Documentation

◆ OCI_DatabaseStartup()

OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseStartup ( const otext *  db,
const otext *  user,
const otext *  pwd,
unsigned int  sess_mode,
unsigned int  start_mode,
unsigned int  start_flag,
const otext *  spfile 
)

#include <api.h>

Start a database instance.

Parameters
db- Oracle Service Name
user- Oracle User name
pwd- Oracle User password
sess_mode- Session mode
start_mode- Start mode
start_flag- Start flags
spfile- Client-side spfile to start up the database (optional)

Possible values for parameter session mode :

  • OCI_SESSION_SYSDBA
  • OCI_SESSION_SYSOPER
Note
External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters If the param 'db' is NULL then a connection to the default local DB is done

Possible (combined) values for parameter start_mode :

  • OCI_DB_SPM_START : start the instance
  • OCI_DB_SPM_MOUNT : mount the instance
  • OCI_DB_SPM_OPEN : open the instance
  • OCI_DB_SPM_FULL : start, mount and open the instance

Possible (combined) values for parameter start_flag :

  • OCI_DB_SPF_DEFAULT : default startup
  • OCI_DB_SPF_FORCE : shuts down a running instance (if needed) using ABORT command and starts a new instance
  • OCI_DB_SPF_RESTRICT : allows database access only to users with both CREATE SESSION and RESTRICTED SESSION privileges
Note
If the client side spfile is not provided, the database is started with its server-side spfile
Returns
TRUE on success otherwise FALSE

Referenced by ocilib::Environment::StartDatabase().

◆ OCI_DatabaseShutdown()

OCI_SYM_PUBLIC boolean OCI_API OCI_DatabaseShutdown ( const otext *  db,
const otext *  user,
const otext *  pwd,
unsigned int  sess_mode,
unsigned int  shut_mode,
unsigned int  shut_flag 
)

#include <api.h>

Shutdown a database instance.

Parameters
db- Oracle Service Name
user- Oracle User name
pwd- Oracle User password
sess_mode- Session mode
shut_mode- Shutdown mode
shut_flag- Shutdown flag
Warning
Possible values for parameter session mode :
  • OCI_SESSION_SYSDBA
  • OCI_SESSION_SYSOPER
Note
External credentials are supported by supplying a null value for the 'user' and 'pwd' parameters If the param 'db' is NULL then a connection to the default local DB is done

Possible (combined) values for parameter shut_mode :

  • OCI_DB_SDM_SHUTDOWN : shutdown the instance
  • OCI_DB_SDM_CLOSE : close the instance
  • OCI_DB_SDM_DISMOUNT : dismount the instance
  • OCI_DB_SDM_FULL : shutdown, close and dismount the instance

Possible (exclusive) value for parameter shut_flag (from Oracle documentation) :

  • OCI_DB_SDF_DEFAULT :
    • Further connects are prohibited.
    • Waits for users to disconnect from the database
  • OCI_DB_SDF_TRANS :
    • Further connects are prohibited
    • No new transactions are allowed.
    • Waits for active transactions to complete
  • OCI_DB_SDF_TRANS_LOCAL :
    • Further connects are prohibited
    • No new transactions are allowed.
    • Waits only for local transactions to complete
  • OCI_DB_SDF_IMMEDIATE :
    • Does not wait for current calls to complete or users to disconnect from the database.
    • All uncommitted transactions are terminated and rolled back
  • OCI_DB_SDF_ABORT :
    • Does not wait for current calls to complete or users to disconnect from the database.
    • All uncommitted transactions are terminated and are not rolled back.
    • This is the fastest possible way to shut down the database, but the next database startup may require instance recovery.
    • Therefore, this option should be used only in unusual circumstances
Returns
TRUE on success otherwise FALSE

Referenced by ocilib::Environment::ShutdownDatabase().