Most user-defined routines

BladeSmith generates only minimal code for most routines you create with the Routine wizard.

The generated code

BladeSmith generates only templates for most user-defined routines.

The generated routine declares the routine, its return type, and arguments. In addition to the arguments you specified when creating the routine, these functions also have an MI_FPARAM argument. Only generated routines that allow null values have code that uses the MI_FPARAM argument. The generated code in these routines uses MI_FPARAM to set the return value of the routine to NULL.

Complete the code

To complete the code for most user-defined routines, you must:
  • Add your declarations, if necessary.
  • Remove the call to mi_db_error_raise(), which raises an error stating that the routine is not implemented.
  • Compute the return value and store it in the Gen_RetVal argument.
  • Remove the call to mi_fp_setreturnisnull() that sets the return value of your routine to NULL, if necessary.

For more information about programming routines, see the HCL OneDB™ DataBlade® API Programmer's Guide.

Examples

The following example DataBlade modules have user-defined routines:
Table 1. Example DataBlade modules that have UDRs
Example DataBlade module Description
Business DataBlade module Provides mathematical functions for calculating loans.
Circle DataBlade module Provides distance and containment functions that operate on opaque data types.
FuzzyMatch DataBlade module Provides functions for handling row data types and comparing opaque data types.
Parts Explosion DataBlade module and DataBladeAPI DataBlade module Provide functions for handling and returning collection data types.
Strings DataBlade module. Provides character-string manipulation functions.

The Mercury DataBlade module exercise in the tutorial provides examples of cast support functions.