INFORMIX DataBlade Developers Kit Tutorial

List of Exercises

Exercise 1: Creating a Simple User-Defined Routine, continued


4

Add code for the AddIntegers() function to the template generated by BladeSmith.

BladeSmith generates two source code files for the AddInts DataBlade module:

  • udr.c. For user-defined routines
  • support.c. For tracing and BladeSmith utility functions (do not edit this file)

The udr.c file you just generated contains:

  • #include statements.
  • the AddIntegers() function template.

You must add to udr.c code that implements the AddIntegers() function.

To create the final version of udr.c, open the file from the AddInts\src\C directory and find the following code:

    /* 
    ** TO DO: Remove this comment and call to 
    **        mi_db_error_raise after implementing 
    **        this function. 
    */ 
    mi_db_error_raise( Gen_Con, MI_EXCEPTION, 
         Function AddIntegers has not been implemented." ); 
    
    

Remove the comment and replace the mi_db_error_raise() statement with the following code to add the two integers:

    Gen_RetVal = Int1 + Int2; 
    
    

Remove the following comment, the call to the mi_fp_setreturnisnull() function, and the statement that sets Gen_RetVal to 0:

    /* 
    ** TO DO: Compute and store your value into Gen_RetVal. 
    ** The call to mi_fp_setreturnisnull informs the 
    ** server that the return value is NULL. 
    */ 
    mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE ); 
    Gen_RetVal = 0;
    
    

Check your source code against the final version of udr.c.

Save your changes to udr.c.


Copyright © 1998, Informix Software, Inc. All rights reserved.