INFORMIX DataBlade Developers Kit Tutorial

List of Exercises

Exercise 3: Creating Distinct Data Types and Casts, continued


4

Add the user-defined routines.

The Mercury DataBlade module uses two user-defined routines to prevent users from entering values below absolute zero in the data types CTemp and FTemp. In this DataBlade module, you implement Assign() functions for the FTemp and CTemp data types. The C functions that implement the Assign() functions are named FTempAssign() and CTempAssign(). The server calls the appropriate routine before it stores a value for either of the two temperature types.

Choose Edit Insert Routine and enter the following information, once for each routine, in the New Routine wizard.

Routine Property FTempAssign Value CTempAssign Value

Routine Name (SQL)

assign

assign

Return type

FTemp

CTemp

Statement Local Variable

No

No

Arguments

Name: temperature

Type: FTemp
Default: none

Name: temperature

Type: CTemp
Default: none

Language

C

C

Options for how the database server calls this routine (page 5)

Only the Routine does not accept NULL arguments check box should be checked; uncheck the Routine may return inconsistent check box.

Only the Routine does not accept NULL arguments check box should be checked; uncheck the Routine may return inconsistent check box.

Routine Name (C)

FTempAssign

CTempAssign

Shared object path

Default

Default

Behavior of routines

Routine is well-behaved

Routine is well-behaved

Special stack requirements

None

None

Cost

0

0

Related routines

None

None

Grant execute privileges

Grant execute privileges

Grant execute privileges

Click Finish and then choose Project Save to save your project.


5

Add the decimal to temperature cast.

Choose Edit Insert Cast and enter the following information in the New Cast wizard.

Cast Property decimal to temperature Value

Cast from type

decimal

Cast to type

temperature

Cast should be called for implicit type conversion

Yes

Cast requires a user defined cast support function

Yes

Support routine name is:

temperatureCast

Grant execute privileges

Grant execute privileges

Click Finish and then choose Project Save to save your project.


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