Mapping cast functions: CastFuncMapper element
The CastFuncMapper element is used for customizing the mappings of the cast functions listed in Table 10‑17. The Integration service generates the default templates for the cast functions.
Table 10‑17 Operand data types for the cast functions
Cast function
Operand data types
Remarks
CAST (AS INTEGER)
<DECIMAL>
<DOUBLE>
<VARCHAR>
Use CAST_AS_INTEGER as FunctionName.
CAST (AS DECIMAL)
<INTEGER>, <INTEGER>, <INTEGER>
<DECIMAL>, <INTEGER>, <INTEGER>
<DOUBLE>, <INTEGER>, <INTEGER>
<VARCHAR>, <INTEGER>, <INTEGER>
Use CAST_AS_DECIMAL as FunctionName.
The second and third operands are the decimal precision and scale, for example 20 and 8 in CAST (AS DECIMAL (20, 8)). Specify the default precision and scale using the iServer configuration variables DefaultDecimalPrecision and DefaultDecimalScale.
CAST (AS DOUBLE)
<INTEGER>
<DECIMAL>
<VARCHAR>
Use CAST_AS_DOUBLE as FunctionName.
CAST (AS VARCHAR)
<INTEGER>, <INTEGER>
<DECIMAL>, <INTEGER>
<DOUBLE>, <INTEGER>
<VARCHAR>, <INTEGER>
<TIMESTAMP>, <INTEGER>
Use CAST_AS_VARCHAR as FunctionName.
The second operand is the string length, for example 50 in CAST(AS VARCHAR (50)). Specify the default string length using the iHub configuration variable DefaultStringLength.
CAST (AS TIMESTAMP)
<VARCHAR>
Use CAST_AS_TIMESTAMP as FunctionName.
Example: Mapping the CAST functions
The default templates generated by the Integration service are not compatible with your database, so you change the mappings to use the CONVERT function. $R represents the return data type:
<CastFuncMapper>
<FunctionMappings>
<FunctionMapping FunctionName="CAST_AS_INTEGER">
CONVERT ($R, $P0)
</FunctionMapping>
<FunctionMapping FunctionName="CAST_AS_DECIMAL">
CONVERT ($R, $P0)
</FunctionMapping>
<FunctionMapping FunctionName="CAST_AS_DOUBLE">
CONVERT ($R, $P0)
</FunctionMapping>
<FunctionMapping FunctionName="CAST_AS_VARCHAR">
CONVERT ($R, $P0)
</FunctionMapping>
<FunctionMapping FunctionName="CAST_AS_TIMESTAMP">
CONVERT ($R, $P0)
</FunctionMapping>
</FunctionMappings>
</CastFuncMapper>