LispWorks User Guide and Reference Manual > 19 Common SQL > 19.9 Using MySQL

NextPrevUpTopContentsIndex

19.9.9 Types of values returned from queries

Common SQL uses the MySQL mechanism that returns values as strings.

By default, Common SQL converts these strings to the appropriate Lisp type corresponding to the column type (or more accurately, the type of the field in the query) according to MySQL type mapping

MySQL type mapping

MySQL column type

Lisp Type

Meaning

All integer types

integer

 

Double

double-float

 

Single

single-float

 

Decimal

rational

 

All String types

string

 

All Binary types

(array (unsigned-byte 8) (*))

 

Date

integer

Universal time

Datetime

integer

Universal time

Timestamp

integer

Universal time

Time

integer

Number of seconds

Year

integer

Number of years

However, if you specify the result type as :string , this eliminates the conversion and the return value is simply the string retrieved by MySQL. For information about specifying the result type for a column (or multiple columns) in a query, see Querying.

Each of the five date-like types (that is, Date, Datetime, Timestamp, Time and Year) can have result type :date , :date-string or :datetime-string with the following effects:

:date

This result type means a Universal time. This is the default except for Year.

:date-string

A string with the format that MySQL uses for Date columns.

:datetime-string

A string with the format that MySQL uses for Datetime columns.

All the numeric types can have result type :int , :single-float or :double-float , causing the appropriate conversion. No check is made on whether the result is actually useful.

String types can have result type :binary , which returns an array.


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex