INFORMIX DataBlade Developers Kit Tutorial

List of Exercises

Exercise 3: Creating Distinct Data Types and Casts, continued


9

Generate the source code and the SQL registration scripts.

See " Generating Code" for detailed instructions.

BladeSmith automatically generates the basic C source code files and the SQL scripts necessary for your DataBlade module to run:

  • The source code files are saved in the Mercury\src\C directory.
  • The SQL scripts are saved in the Mercury\scripts directory.

The BladeSmith portion of this exercise is complete; you can exit BladeSmith.


10

Add your source code to the templates generated by BladeSmith.

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

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

Make the following modifications to the source code in udr.c:

  • Remove the following code from each function:
                 /*
                 ** 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 Distance has not been implemented." )
    
    
  • Add code in the section marked TO DO: Compute and store your value into Gen_RetVal.

    To find the code you need to add for each function, look at the final version of udr.c or view the changes function-by-function in the following table (the functions might not be in the same order as in your udr.c file).

    Function Name Description of Change

    CTempAssign()

    Verify that an entered CTemp value is greater than -273.15; send an error message if it is not.

    CTempCast()

    Verify that an entered FTemp value is greater than -459.6; perform conversion to Celsius if it is or send an error message if it is not.

    DecToTemp()

    Because of data type impedance between SQL and C, use the ESQL/C conversion function dectodbl() to convert the Informix server decimal data type to the C double type.

    The double precision data type is defined as the C type double.

    FTempAssign()

    Verify that an entered FTemp value is greater than -459.6; send an error message if it is not.

    FTempCast()

    Verify that an entered CTemp value is greater than -273.15; perform conversion to Fahrenheit if it is or send an error message if it is not.

    IntToTemp()

    Both integer and double precision are defined as C types, so you can make the conversion in C.

Save the changes to udr.c.


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