2.5 Defining a Database
Once you have installed Mimer SQL and added a license key, the next step is to define and configure a database. The database can either be a local or a remote database. You can also associate the database with an ODBC data source name.
You use the ODBC routine SQLConfigDataSource to define and configure Mimer SQL databases and data sources from a program. The routine is documented in ODBC Supplementary Information and the Mimer specific parameters are documented in Mimer Packaging Parameters.
You use SQLConfigDataSource to perform the same tasks as you would normally perform using the Mimer Administrator. It is possible to override any defaults for parameters and, if you like, to invoke the same dialog boxes as the Mimer Administrator uses to enable the user of your application to perform customization for their specific environment.
2.5.1 Defining a Remote Database
The following sections document examples of how to define a remote database. For more examples, see Example Configuration Program. For more information on the parameters used, see Mimer Packaging Parameters.
If any parameters that are specific to a local or remote database definition are given, the system will create the appropriate database definition. In the examples below, the parameters NODE and PROTOCOL indicates that a remote database definition should be created.
126.96.36.199 Example 1
The following C example will create the definition for a remote database on the host db.mimer.com. The client will communicate using the TCP/IP protocol.rc = SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"MIMER", "DSN=MyRemoteODBC\0DATABASE=MyRemoteMIMER\0" "NODE=db.mimer.com\0" "PROTOCOL=tcp\0" "DESCRIPTION=This is my remote database\0\0");
The example above creates a new, system-wide, data source MyRemoteODBC and also a remote Mimer SQL definition for the database MyRemoteMIMER.
As the first (hwndParent) parameter is set to NULL, the operation is performed without displaying any dialog boxes.
188.8.131.52 Example 2
Alternately, you can achieve the same result as in example 1 with the following two calls:rc = SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"MIMER", "DSN=MyRemoteODBC\0DATABASE=MyRemoteMIMER\0" "DESCRIPTION=This is my remote database\0\0");
andrc = SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"MIMER", "DATABASE=MyRemoteMIMER\0" "NODE=db.mimer.com\0" "PROTOCOL=tcp\0" "DESCRIPTION=This is my remote database\0\0");
First, the data source is created and then, in a separate call, the remote Mimer SQL definition is created. This shows some important points regarding how SQLConfigDataSource is implemented.
When the input parameters are analyzed, the system decides which objects to work with. If a DSN parameter is specified, a data source is created.
Since the parameter is ODBC_ADD_SYS_DSN, this means that any existing definitions of MyRemoteODBC and MyRemoteMimer are overwritten.
If you want to change the NODE argument for an existing database definition the following call would do that:rc = SQLConfigDataSource(NULL,ODBC_CONFIG_SYS_DSN,"MIMER", "DATABASE=MyRemoteMIMER\0" "NODE=newnodename\0\0");
2.5.2 Defining and Configuring a Local Database
To create a local database, you specify one or more local parameters in a call to SQLConfigDataSource.
The following C program will create a local database definition with 1000 2K pages in the bufferpool.rc = SQLConfigDataSource(NULL,ODBC_ADD_SYS_DSN,"MIMER", "DATABASE=MyLocalMimer\0" "DIRECTORY=C:\DB6\0" "Pages2K=1000\0\0");
As the first argument (hwndParent) is set to NULL, the call will not display any dialog boxes.
DATABASE and DIRECTORY are required parameters that have to be specified when the first argument (hwndParent) is set to NULL.
The number of 2K pages will be set to 1000 and all other parameters will be set to their default values.
You can view the changes made by the installation program in the Registry Editor (regedit.exe) under the following keys:HKEY_LOCAL_MACHINE: Software\Mimer\Mimer SQL\SQLHosts\xxx Software\ODBC\ODBC.INI\yyy HKEY_CURRENT_USER: Software\ODBC\ODBC.INI\zzz
Where xxx is the database name, yyy is system data source name and zzz is user data source name.
2.5.3 Error Handling
Note that if the configuration is handled as a number of calls, then the error handling, from the installation program's point of view, can much more easily determine what went wrong.
In Example 1, it is possible that a data source was created even though the database definition was not. See I_InstError for more information on error handling.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40