company logo

Loading options from configuration

Application option or user specific options can be stored in each database. In the ODC_Options extent, any number of configurations might be stored. Usually, user configurations are stored referring to the user's login name. But there might be also common application configurations for different applications or common configurations for specific tasks, which might be defined in addition.

Options defined in a database configuration may be loaded into the application by calling Database::initializeOptions(). An application may refer to any number of configurations. Configuration names are not case sensitive. When not passing a configuration name, default configuration is retrieved as follows:

  1. A configuration with the user's name is searched for. The user name is retrieved from the operating system or from the system variable USER_NAME.
  2. When no configuration has been defined for the user, the configuration name is taken from the DEFAULT_CONFIGURATION settings.
  3. When still no configuration could be located, the first configuration in the list is used as default configuration.

In order to load multiple configurations, initializeOptions() has to be called with appropriate configuration names.

int8 db_context::doAfterOpen ( ) {

  // initialize user or default options

  database().initializeOptions();

  // initialize common application options

  database().initializeOptions("myApplication");

  return true;

}