Next Previous Up Top Contents Index

1 The SQL-ODBC Library

1.6 Data types and conversions

The datatypes that relational DBMSes use are different from those Dylan uses. The SQL-ODBC library provides classes that represent these low-level relational datatypes, along with a table that defines the mapping from these datatypes to Dylan datatypes (Table 1.6, page 38). The methods on the record class consult this mapping when performing data coercion.

The datatypes of host variables are limited to the Dylan datatypes that appear in Table 1.6. Host variables come in two flavors: read and write. Host variables appearing in an into clause of an SQL SELECT statement are write parameters, and all other host variables are read parameters.

Table 1.6 Mapping from DBMS to Dylan datatypes

DBMS type

SQL type

Dylan type

sql_char

<sql-char>

<character>

sql_varchar

<sql-varchar>

<string>

sql_longvarchar

<sql-longvarchar>

<string>

sql_decimal

<sql-decimal>

<string>

sql_numeric

<sql-numeric>

<string>

sql_bit

<sql-bit>

<integer>

sql_tinyint

<sql-tinyint>

<integer>

sql_smallint

<sql-smallint>

<integer>

sql_integer

<sql-integer>

<integer>

sql_bigint

<sql-bigint>

<integer>

sql_real

<sql-real>

<single-float>

sql_float

<sql-float>

<single-float>, <double-float> or <extended-float>

sql_double

<sql-double>

<double-float>

sql_binary

<sql-binary>

<binary>

sql_varbinary

<sql-varbinary>

<binary>

sql_longvarbinary

<sql-longvarbinary>

<binary>

sql_date

<sql-date>

<date>

sql_time

<sql-time>

<time>

sql_timestamp

<sql-timestamp>

<timestamp>

To retrieve integer elements from databases that may contain more than 30-bit data, you must use the generic-arithmetic library or a run-time error will occur. The Dylan SQL-ODBC library must also be prepared.

Example library and module definition:

define library sql-example
  use functional-dylan;
  use generic-arithmetic;
  use sql-odbc;

export sql-example; end library;

define module sql-example use generic-arithmetic-functional-dylan; use sql-odbc; end module;


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

Next Previous Up Top Contents Index