|
|
Knowledge Base
Document information| Document ID: | 808 |
|---|
| Subject: | Converting from one data type to another in ODBC |
|---|
| Creation date: | 7/29/09 4:36 PM |
|---|
| Last modified on: | 7/29/09 4:36 PM |
|---|
Details
ODBC specifications includes a function called CONVERT that can be used
to convert data from one datatype to another. This function is equivalent to
the CAST function defined in SQL-92. The syntax is as follows:
{fn CONVERT (value-exp, data-type) }
Example:
select
{fn
CONVERT
(dob
, SQL_CHAR
)} from
Student
The second parameter to this function should be a valid ODBC data type. Following list
contains possible values.
- SQL_CHAR
- SQL_VARCHAR
- SQL_LONGVARCHAR
- SQL_DECIMAL
- SQL_NUMERIC
- SQL_SMALLINT
- SQL_INTEGER
- SQL_DOUBLE
- SQL_BINARY
- SQL_VARBINARY
- SQL_TYPE_DATE
- SQL_TYPE_TIME
- SQL_TYPE_TIMESTAMP
Add a comment to this document
Do you have a helpful tip related to this document that you'd like to share
with other users? Please add it below. Your name and tip will appear at the
end of the document text.
|