Tim Bunce wrote:
> 
> Do you have a reference to any docs that explain the transation
> of the types and/or what the SQL_TYPE_ and SQL_CODE_ prefixes
> are all about?
> 

All I use is mentioned in the DBI docs:

 SQL/CLI specification: 

<http://www.jtc1sc32.org/sc32/jtc1sc32.nsf/Attachments/DF86E81BE70151D58525699800643F56/$FILE/32N0595T.PDF>

 MS ODBC SDK:
 <http://msdn.microsoft.com/>

I can't explain, how the specs evolved, I can only guess:

It seems, that earlier ODBC specs did not contain any temporal
datatypes (in the core) ...

  SQL.H:
  /* SQL data type codes */
  #if (ODBCVER >= 0x0300)
  #define SQL_DATETIME        9
  #endif

... but the Microsoft SQL Extensions did!

  SQLEXT.H:
  /* SQL extended datatypes */
  #define SQL_DATE            9
  #define SQL_TIME           10
  #define SQL_TIMESTAMP      11

In ODBCVER == 0x0300 they moved it to the core. (Maybe, they aligned
with SQL/CLI?) So they defined:

 a) a generic date/time datatype: SQL_DATETIME = 9
    (coincidental SQL_DATETIME == SQL_DATE?)
 b) some subcodes:

  SQL.H:
  /* SQL date/time type subcodes */
  #if (ODBCVER >= 0x0300)
  #define SQL_CODE_DATE       1
  #define SQL_CODE_TIME       2
  #define SQL_CODE_TIMESTAMP  3
  #endif

 d) some shortcuts, where

      SQL_TYPE_xxx = 10 * SQL_DATETIME + SQL_CODE_xxx

  SQL.H:
  /* One-parameter shortcuts for date/time data types */
  #if (ODBCVER >= 0x0300)
  #define SQL_TYPE_DATE      91
  #define SQL_TYPE_TIME      92
  #define SQL_TYPE_TIMESTAMP 93
  #endif

The SQL_INTERVAL story looks similar. Unfortunately, ODBC and
SQL/CLI differ in the defined names:

  ODBC interval codes             : SQL_CODE_*
  SQL/CLI Interval qualifier codes: SQL_*


Steffen

Reply via email to