Functions

Initializing the library


Detailed Description

To use OCILIB, it first needs to be initialized through a call to OCI_Initialize().

Then, the application connects to server, executes queries...

Finally, OCILIB resources must be released by OCI_Cleanup()

Note:

The following objects are automatically freed by the library:

Warning:

All other standalone object instances (mutexes, threads, dates, lobs, ...) ARE NOT freed.

Example
#include "ocilib.h"

int main(void)
{
    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    /* ... application code here ... */

    OCI_Cleanup();

 
    return EXIT_SUCCESS;
}

Functions

OCI_EXPORT boolean OCI_API OCI_Initialize (POCI_ERROR err_handler, const mtext *lib_path, unsigned int mode)
 Initialize the library.
OCI_EXPORT boolean OCI_API OCI_Cleanup (void)
 Clean up all resources allocated by the library.
OCI_EXPORT unsigned int OCI_API OCI_GetOCICompileVersion (void)
 Return the version of OCI used for compilation.
OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion (void)
 Return the version of OCI used at runtime.
OCI_EXPORT unsigned int OCI_API OCI_GetImportMode (void)
 Return the Oracle shared library import mode.
OCI_EXPORT unsigned int OCI_API OCI_GetCharsetMetaData (void)
 Return the metadata charset type.
OCI_EXPORT unsigned int OCI_API OCI_GetCharsetUserData (void)
 Return the user data charset type.
OCI_EXPORT void OCI_API OCI_EnableWarnings (boolean value)
 Enable or disable Oracle warning notifications.
OCI_EXPORT void OCI_API OCI_SetErrorHandler (POCI_ERROR handler)
 Set the global error user handler.

Function Documentation

OCI_EXPORT boolean OCI_API OCI_Initialize ( POCI_ERROR  err_handler,
const mtext *  lib_path,
unsigned int  mode 
)

Initialize the library.

Parameters:
err_handler - Pointer to error handler procedure (optional)
lib_path - Oracle shared library path (optional)
mode - Environment mode

Possible values for parameter mode:

  • OCI_ENV_DEFAULT : default mode
  • OCI_ENV_THREADED : multithreading support
  • OCI_ENV_CONTEXT : thread contextual error handling
  • OCI_ENV_EVENTS : enables events for subscription
Note:

This function must be called before any OCILIB library function.

  • It installs the error handler
  • It loads the Oracle shared library located in the path pointed by 'home'
Warning:

The parameter 'home' is only used if OCILIB has been built with the option OCI_IMPORT_RUNTIME (default on MS windows but NOT on Unix systems

Warning:

If the parameter 'lib_path' is NULL, the Oracle library is loaded from system environment variables

Warning:

OCI_Initialize() should be called ONCE per application

Returns:

TRUE on success otherwise FALSE (only with Oracle runtime loading mode if the oracle shared libraries can't be loaded or if OCI subsystem cannot be initialized)

Definition at line 463 of file library.c.

OCI_EXPORT boolean OCI_API OCI_Cleanup ( void   ) 

Clean up all resources allocated by the library.

Note:

This function must be the last OCILIB library function call.

  • It deallocates objects not explicitly freed by the program (connections, statements, ...)
  • It unloads the Oracle shared library
Warning:

OCI_Cleanup() should be called ONCE per application

Returns:
TRUE

Definition at line 1205 of file library.c.

OCI_EXPORT unsigned int OCI_API OCI_GetOCICompileVersion ( void   ) 

Return the version of OCI used for compilation.

Note:
  • with linkage build option, the version is determined from the oci.h header through different ways
  • with runtime loading build option, the version is set to the highest version of OCI needed by OCILIB, not necessarily the real OCI version

Definition at line 1329 of file library.c.

OCI_EXPORT unsigned int OCI_API OCI_GetOCIRuntimeVersion ( void   ) 

Return the version of OCI used at runtime.

Note:
  • with linkage build option, the version is determined from the oci.h header through different ways
  • with runtime loading build option, the version determined from the symbols dynamically loaded.

Definition at line 1341 of file library.c.

Referenced by OCI_GetVersionConnection().

OCI_EXPORT unsigned int OCI_API OCI_GetImportMode ( void   ) 

Return the Oracle shared library import mode.

Note:
Possible values are:
  • OCI_IMPORT_MODE_LINKAGE
  • OCI_IMPORT_MODE_RUNTIME

Definition at line 1353 of file library.c.

OCI_EXPORT unsigned int OCI_API OCI_GetCharsetMetaData ( void   ) 

Return the metadata charset type.

Note:
Possible values are:
  • OCI_CHAR_ANSI
  • OCI_CHAR_WIDE

Definition at line 1365 of file library.c.

OCI_EXPORT unsigned int OCI_API OCI_GetCharsetUserData ( void   ) 

Return the user data charset type.

Note:
Possible values are:
  • OCI_CHAR_ANSI
  • OCI_CHAR_WIDE

Definition at line 1377 of file library.c.

OCI_EXPORT void OCI_API OCI_EnableWarnings ( boolean  value  ) 

Enable or disable Oracle warning notifications.

Parameters:
value - enable/disable warnings
Note:
Default value is FALSE

Definition at line 1414 of file library.c.

OCI_EXPORT void OCI_API OCI_SetErrorHandler ( POCI_ERROR  handler  ) 

Set the global error user handler.

Parameters:
handler - Pointer to error handler procedure
Note:
Use this call to change or remove the user callback error handler installed by OCI_Initialize()

Definition at line 1426 of file library.c.