MySQL ODBC查询 - CONVERT函数

时间:2015-12-22 20:15:37

标签: mysql

我试图编写一个ODBC标准查询,以便在多个可能的ODBC驱动程序中使用。但是在查询MySQL源代码时,我得到了一些非标准的行为。我希望我只缺少一个配置,但我担心MySQL对ODBC标准的支持是不完整的。

这是我试图发送的查询,但不起作用:

SELECT  0 AS GroupColumnID 
,  {fn CONVERT(NULL,SQL_DATE)} AS GroupStartRangeDTS 
,  {fn CONVERT(NULL,SQL_DATE)} AS GroupEndRangeDTS 
, 0 AS FilterColumnID 
, {fn CONVERT(NULL,SQL_DATE)} AS FilterStartRangeDTS 
, {fn CONVERT(NULL,SQL_DATE)} AS FilterEndRangeDTS 
, 5 AS ETLBatchID 
, {fn CONVERT(NULL,SQL_VARCHAR)} AS GroupingFormat 
, {fn CONVERT('Not Defined',SQL_VARCHAR)} AS GroupingField 
, {fn CONVERT(COUNT(*),SQL_BIGINT)} AS TotalRows 
, 71 AS TableID 
, {fn CURRENT_TIMESTAMP()} AS LastModifiedDTS 
FROM sakila.actor ORDER BY GroupingField, TotalRows

如果我将查询修改为这样,它会在MySQL上执行,但不会在其他ODBC数据源上执行。

SELECT  0 AS GroupColumnID 
,  {fn CONVERT(NULL,DATETIME)} AS GroupStartRangeDTS 
,  {fn CONVERT(NULL,DATETIME)} AS GroupEndRangeDTS 
, 0 AS FilterColumnID 
, {fn CONVERT(NULL,DATETIME)} AS FilterStartRangeDTS 
, {fn CONVERT(NULL,DATETIME)} AS FilterEndRangeDTS 
, 5 AS ETLBatchID 
, {fn CONVERT(NULL,CHAR)} AS GroupingFormat 
, {fn CONVERT('Not Defined',CHAR)} AS GroupingField 
, COUNT(*) AS TotalRows 
, 71 AS TableID 
, {fn CURRENT_TIMESTAMP()} AS LastModifiedDTS 
FROM saklia.actor ORDER BY GroupingField, TotalRows

这是我缺少的配置还是MySql的已知问题?文档表明它接受标准的SQL数据类型(SQL_DATETIME,SQL_VARCHAR),但是当通过驱动程序运行查询时,我在这些点上的查询中出现错误。

我在Windows 64位计算机上运行MySQL ODBC Connector 5.3.4。我的开发机器和测试服务器都遇到了同样的问题。

0 个答案:

没有答案