Using the ODBC Sample Exit

A sample exit which interfaces to a database using Open Data Base Connectivity (ODBC) is supplied as file odbc.bsh in the Exits folder. Installations can make a copy of this file and edit it to make it conform to their needs.

Defining an ODBC Data Source

Under Microsoft Windows 2000 or XP an ODBC data source for use with the MAINVIEW Data Server can be established using the ODBC tool. It is accessed from Settings→Control Panel→Administrative Tools, or Settings→Control Panel→Data Sources (ODBC).

To define a new User Data Source click "Add...". This brings up a dialog which looks like this:

If you do not find the drivers for your DBMS listed, you will need to install the drivers. Please contact your DBA or your DBMS vendor for the drivers. Choose the driver for the database system which is to receive the data, and click Finish. This will bring you to a setup screen specific to your chosen database system. For example, the Microsoft Access Driver looks like this:

Fill in the fields as required for the database that you wish to access, and click OK. The Data Source name that you selected will show up in the User Data Source list in the ODBC manager, and is the name that will be used to connect to your data base from the exit.

Modifying the Exit

Make the following modifications to a copy of the odbc.bsh file to customize it. These changes can be made with a text editor such as Notepad.

1. Change the exit name.

Find the line in the exit that reads as follows:

  return "ODBC exit";

Replace the text between the quote marks with your own exit description such as "Production DB2". This name will show up in the setup dialog.

2. Change the Data Source.

Find the line in the exit that reads as follows:

String url = "jdbc:odbc:mainview.dsn";

Replace mainview.dsn with the name that you gave to your data source.

Exit Operation

The sample ODBC exit creates a table in your database with the name "product_view" where product and view are the names of the MAINVIEW components providing the data.

The table will have columns for the sample interval end time, the row number, the interval duration, and the names identifying where the data was collected. Following that will be one column for each field selected during setup. 

Using your normal database management tools, you can modify the table so that the time and row columns become a unique composite key. A unique key prevents duplicate entries from being made when the server is interrupted while recording.