I have a problem of transferring data from one odcbc-complilant database to another where the field types are known to be similar but not identical. I'm thinking of a function defined as follows:-

Code: Select all

`coerce:(core::value SourceData, odbc_native::sqlDataType DestinationType)->core::value CoercedValue`

The brutal force approach uses the fact that there are 12 codes of sql data types, viz.,

Code: Select all

```
sql_unknown_type : sqlDataType = 0.
sql_char : sqlDataType = 1.
sql_numeric : sqlDataType = 2.
sql_decimal : sqlDataType = 3.
sql_integer : sqlDataType = 4.
sql_smallint : sqlDataType = 5.
sql_float : sqlDataType = 6.
sql_real : sqlDataType = 7.
sql_double : sqlDataType = 8.
sql_datetime : sqlDataType = 9.
sql_varchar : sqlDataType = 12.
```

Code: Select all

```
value =
none();
boolean(boolean Value);
unsigned64(unsigned64 Value);
integer64(integer64 Value);
unsigned(unsigned Value);
integer(integer Value);
real(real Value);
char(char Value);
string(string Value);
string8(string8 Value);
binary(binary Value);
binaryNonAtomic(binaryNonAtomic Value);
object(object Value);
gmtTimeValue(gmtTimeValue Value);
localTimeValue(localTimeValue Value);
pointer(pointer Value);
handle(handle Value).
```

The value2String method goes something like ...

Code: Select all

```
clauses
coerce(Source, Type)=str_value(Str, Type):-
core::value2String(Source)=Str.
```

Before I get bogged down with implementing the s

**tr_value**predicate I would like to find out if there are better ways of achieving the intended result than these thoughts.