Was this helpful?
Requirements for Data Type Coercion
When you define a new data type, you must also define the coercion routines that support the data type. The following coercion routines are required:
A coercion from any data type to the same data type.
This coercion routine is used by the DBMS Server in variety of instances, for example, during retrieve into and create table as select statements or when changing the length of a data type.
A coercion from the new data type to the SQL data type that represents this data in user interface applications (such as Query-By-Forms or Report-By-Forms).
User interface applications do not accept user-defined data types directly. Therefore, you must provide a coercion routine to convert your data type to a standard SQL data type for external representation. This coercion routine must be compatible with the input coercion routine as follows:
The output of this coercion routine must be acceptable as input to the input coercion routine. The output of the input coercion routine must be acceptable as input to this coercion routine.
An example of a coercion routine for converting from an internal to an external representation is shown here:
sprintf(obuffer, "(%11.3f, %11.3f)", point.x,point.y);
An input coercion.
This coercion must convert data coming from an SQL insert or update query to internal representation. Data represented as character strings in Embedded SQL is sent to the DBMS Server as the varchar data type. At least one input coercion routine, which converts varchar to your data type, is required. The input coercion routine must be compatible with the external coercion routine as follows:
The output of this coercion routine must be acceptable as input to the output coercion routine. The output of the output coercion routine must be acceptable as input to this coercion routine.
An example of a coercion routine for converting from an external to an internal representation is shown here:
sscanf(inbuffer, "(%F, %F%1s %1s", &point.x, &point.y,
end_paren,junk);
Coercions to and from the II_LONGTEXT data type.
This data type is similar to varchar but is used in different contexts. For example, it is used to display data from various utility programs, such as auditdb.
Last modified date: 11/28/2023