MySQL使用ODBC日期参数生成不正确的结果

时间:2013-05-16 13:51:12

标签: mysql crystal-reports odbc

我最近将我的MySQL版本升级到5.6.10(Linux上的社区版),随后我无法通过MySQL ODBC驱动程序3.5.1正确运行与MySQL 5.0.24a通信良好的Crystal Report。 / p>

该报告是基于一个SQL命令构建的,如果我手动输入查询并将日期记录到MySQL客户端,但是通过ODBC(它重新格式化日期中的查询为{d' 2013-05-15'} MySQL返回随机结果,这意味着一次运行将返回没有负值的结果,另一次运行只返回负值,另一次运行将不返回任何结果。实际上,我实际上得到了完整的报告,但这是不可预测的。

我已将其缩小到日期参数范围,但在升级到Crystal Reports 2011以及MySQL ODBC 5.2之后 - 问题仍然存在。我通过更改" date"来解决这个问题。参数为"字符串"参数但这并不理想。

MySQL 5.6.10服务器上的其他所有内容似乎运行正常,我仍在尝试确定5.0和5.6之间是否有关于ODBC处理方式的更改,但到目前为止我还是我没有运气弄清楚为什么这样做很奇怪。

这里是查询的一部分,带有相关参数...

    select sql_no_cache
    if(CCT.creditCardTypeName is not null, CCT.creditCardTypeName, if(OPBML.orderPaymentBMLID is not null, 'Bill Me Later', 'Cash/Check')) as theType,
    'orderPayment               ' as source,
    date_format(OP.authorizationDate, '%Y-%m-%d') as theDate,
    if (OPC.checkNumber is not null, OPC.checkNumber, '') as checkNum,
    if (OPWT.wireTransferDate is not null, OPWT.wireTransferNumber, '') as wtNum,
    concat(C.lastName, ', ', C.firstName) as custName,
    O.orderNumber,
    OP.amount
from
    orders O
    inner join orderPayment OP on (O.ordersID=OP.ordersID)
    inner join paymentMethod PM on (PM.paymentMethodID=OP.paymentMethodID)
    inner join customer C on (C.customerID=O.customerID)
    inner join partner P on (C.partnerID = P.partnerID and P.businessUnit = {?businessUnit})
    left outer join orderPaymentBML OPBML on (OP.orderPaymentID=OPBML.orderPaymentID)
    left outer join orderPaymentCheck OPC on (OP.orderPaymentID=OPC.orderPaymentID)
    left outer join orderPaymentCreditCard OPCC on (OP.orderPaymentID=OPCC.orderPaymentID)
    left outer join orderPaymentWireTransfer OPWT on (OP.orderPaymentID=OPWT.orderPaymentID)
    left outer join creditCardType CCT on (CCT.creditCardTypeID=OPCC.creditCardTypeID)
where
    OP.authorizationDate between date_add({?date},INTERVAL "3:0:01" HOUR_SECOND) and 
    date_add( date_add({?date}, INTERVAL 1 DAY), INTERVAL "3:0:00" HOUR_SECOND) and
    PM.paymentMethodAbbreviation in ('BM', 'CC', 'CH', 'WT')

谢谢, --SJ

1 个答案:

答案 0 :(得分:1)

最后评论是决议:

“好的 - 我想我已经解决了这个问题。结果出现了一个副作用5.6.4更改关键字影响文字的方式是必须在ODBC驱动程序中指定字符集。我为其指定了正确的字符集DB现在得到了正确的结果。“

猜测大多数人已经明确指出,我们没有指定它,它只是有效。'

相关问题