Tutorial exercise 5: Using interfaces

This exercise demonstrates how to use interfaces to define how one DataBlade® module depends on another. This exercise has 16 steps. It takes approximately one hour to complete

About this task

You are going to create two DataBlade modules, Point and Circle:
  • The Point DataBlade module contains the Point opaque data type and the Distance() function.
  • The Circle DataBlade module contains the Circle opaque data type and the Contains() function.

Because the Circle data type has a member of type Point, and the Contains() function uses the Distance() function, the Circle DataBlade module depends on the Point DataBlade module. To use the Circle DataBlade module, users must first install and then register the Point DataBlade module by using BladeManager.

By using interfaces, you set up a dependency so that users cannot register the Circle DataBlade module unless the Point DataBlade module is already registered. If a user tries to register the Circle DataBlade module first, BladeManager looks for the Point DataBlade module and performs one of the following actions:
  • If the Point DataBlade module is already installed on the database server, BladeManager prompts the user to register it and only then proceeds to register the Circle DataBlade module.
  • If the Point DataBlade module is not installed, BladeManager does not register the Circle DataBlade module.

In this exercise, however, you use the DBDK Visual C++ Add-In to register the DataBlade module you create instead of BladeManager. The add-in does not check for dependencies; you must register the DataBlade modules in the correct order.

This exercise also shows how a DataBlade module routine can call a routine from another DataBlade module directly by using a wrapper function instead of an SQL statement.