Next Previous Up Top Contents Index

1.5 Result-set collections

1.5.5 Coercion policies

In the SQL-ODBC library, the element method on the record class encapsulates all coercions of data retrieved from a database. This method can return columns with or without coercion: as low-level SQL data-types (no conversion), as Dylan data-types, or as user-defined types. The coercion-policy: init-keyword of the <sql-statement> class determines this behavior.

If the coercion-policy: init-keyword is $no-coercion, coercions are not performed. Hence, your application will be processing objects with low-level SQL datatypes. This option has the lowest overhead but the most restrictions: the values returned from the element method may not be valid (values may change as storage may be reused) after the next call to the next-state method returned by forward-iteration-protocol.

The value of $default-coercion for the coercion-policy: init-keyword (the default value) indicates that default coercion should be performed: the data retrieved from the database is coerced to the corresponding Dylan objects.

A sequence for the coercion-policy: init-keyword instructs the SQL library to perform specific data coercion on the data retrieved from the database. Essentially, each element of the limited sequence is a data coercion function which will be invoked using the objects returned from the database as the argument.

When there is a one-to-one correspondence between an SQL datatype and a built-in or user-defined Dylan datatype, use the <record> class to perform the conversion. When multiple columns define a Dylan object or one column defines multiple Dylan objects, use the liaison function to perform the conversion.


OLE, COM, ActiveX and DBMS Reference - 31 MAR 2000

Next Previous Up Top Contents Index