[unixODBC-support] Columntype datetime2 returned by SQLDescribeCol strange

Björn Lundin b.f.lundin at gmail.com
Mon Oct 1 07:43:05 BST 2012


Hi!

This is posted also to freetds maillist, but I now think it should be posted here.

I have a Raspberry Pi (arm platform) running debian 6
which has unixodbc .

I installed this :

sudo apt-get install unixodbc unixodbc-dev odbcinst freetds
freetds-dev freetds-bin

and when I run a program towards a sql-server I get

Message: [Proc=SQLDescribeParam][Server=][State=IM001][unixODBC][Driver
Manager]Driver does not support this function

Ok, too bad, but I can live without that function.

However, when I run the same code on a windows client, it goes well,
using MS native client.


Anyway, my real problem is that when I have a DateTime2(3) column,
SQLDescribeCol returns
* SQL_VARCHAR

with MS native windows driver I get one of (not sure which, I treat
them equally)
* SQL_TYPE_TIMESTAMP
* SQL_DATETIME

Is there a way around this, to tell the client library to return a
correct datatype?

I'm not quite sure what lib or layer I'm supposed to look at.
odbc or tds, but I guess odbc. 

isql does this:
(its column IXXLUTS that is behaving strange)
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> help bseq
+------------------+--------------+------------+--------------+----------+-------------+------------
| TABLE_QUALIFIER  | TABLE_OWNER  | TABLE_NAME | COLUMN_NAME  |
DATA_TYPE| TYPE_NAME   | PRECISION
+------------------+--------------+------------+--------------+----------+-------------+------------
| sattmate         | dbo          | BSEQ       | BSQPSTO      | 12
  | varchar     | 2
| sattmate         | dbo          | BSEQ       | BSQDSTO      | 12
  | varchar     | 2
| sattmate         | dbo          | BSEQ       | BSQTRTYP     | 4
  | int         | 10
| sattmate         | dbo          | BSEQ       | BSQID        | 12
  | varchar     | 4
| sattmate         | dbo          | BSEQ       | BSQPRIOR     | 4
  | int         | 10
| sattmate         | dbo          | BSEQ       | BSQBEGPR     | 12
  | varchar     | 15
| sattmate         | dbo          | BSEQ       | IXXLUPD      | 12
  | varchar     | 12
| sattmate         | dbo          | BSEQ       | IXXLUTS      | -9
  | datetime2   | 23
+------------------+--------------+------------+--------------+----------+-------------+------------


+------------+-------+-------+---------+---------+------------+--------------+-----------------
| LENGTH     | SCALE | RADIX | NULLABLE| REMARKS | COLUMN_DEF |
SQL_DATA_TYPE| SQL_DATETIME_SUB
+------------+-------+-------+---------+---------+------------+--------------+-----------------
| 2          |       |       | 0       |         | (' ')      | 12
      |
| 2          |       |       | 0       |         | (' ')      | 12
      |
| 4          | 0     | 10    | 0       |         | ((1))      | 4
      |
| 4          |       |       | 0       |         | (' ')      | 12
      |
| 4          | 0     | 10    | 1       |         | ((1))      | 4
      |
| 15         |       |       | 0       |         | (' ')      | 12
      |
| 12         |       |       | 0       |         | (' ')      | 12
      |
| 46         |       |       | 0       |         |            | -9
      |
+------------+-------+-------+---------+---------+------------+--------------+-----------------


+------------------+-----------------+-------------+-------------+
| CHAR_OCTET_LENGTH| ORDINAL_POSITION| IS_NULLABLE | SS_DATA_TYPE|
+------------------+-----------------+-------------+-------------+
| 2                | 1               | NO          | 39          |
| 2                | 2               | NO          | 39          |
|                  | 3               | NO          | 56          |
| 4                | 4               | NO          | 39          |
|                  | 5               | YES         | 38          |
| 15               | 6               | NO          | 39          |
| 12               | 7               | NO          | 39          |
|                  | 8               | NO          | 0           |
+------------------+-----------------+-------------+-------------+

SQLRowCount returns 8

/Björn
Skickat från min iPad


More information about the unixODBC-support mailing list