【问题标题】:Trouble with QODBC SQLQODBC SQL 的问题
【发布时间】:2014-08-28 14:41:37
【问题描述】:

好的。在过去的几天里,我一直在努力做世界上最简单的报告……

因此,在弄清楚表关联并提取样本数据之后,我注意到我需要改变我提取数据的方式。 其中一部分是从 Invoice 表中提取 Year-to-Date。 但是,qodbc很笨(可能是我,但怪司机让我好过)

SELECT * FROM Invoice WHERE TimeCreated > '2014-01-01 00:00:00.000' 不断给我Invalid operand for operator: > 的错误

搜索 Google 对我没有任何帮助。
Soooo...我需要按日期字段搜索的帮助。有人有任何想法或建议吗?

此外,奖励积分但相关...还有其他人对 qodbc 驱动程序的速度有疑问吗?有些表的搜索速度与 mysql 一样快,但有些表......神圣的废话。一个简单的查询需要 10 分钟。提高这些速度的想法?

【问题讨论】:

    标签: odbc quickbooks


    【解决方案1】:

    日期格式

    SELECT *
    from InvoiceLine
    WHERE Txndate >= {d '2005-09-23'}
    

    时间戳格式

    SELECT *
    FROM Customer
    WHERE TimeCreated = {ts '1999-07-29 14:24:18.000'}
    
    SELECT *
    from InvoiceLine
    WHERE TimeModified >= {ts '2005-09-23 00:00:00.000'}
    

    参考:http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2203/50/how-are-dates-formatted-in-sql-queries-when-using-the-quickbooks-generated-time-stamps

    如何让 QODBC 运行得更快

      Keep in mind that QODBC is not a database tool, but rather a translation tool. QuickBooks is a non-normalized flat file system which has no indexes available and will not perform like SQL Server or dBase files. Every transaction you request must be translated and communicated to QuickBooks via large complicated XML transactions.
    
      Try and keep your result set as small as possible to get a feel for the system, carefully design and test any multi-file joins, and keep the number of returned fields to a minimum for maximum performance.
    
      Our main goal is to make it easier to access QuickBooks data in a standardised database-like fashion, but queries must be optimized to perform as fast as possible.
    
      Also, try and use ranges of dates on TxnDate, TxnDateMacro and TimeModified as much as possible to narrow down the data to the smallest possible segment. For example, make something similar to this in the first part of your WHERE clause:
    
      Invoice.TimeModified >= {ts'2003-09-01 17:01:09'} AND
      Invoice.TimeModified <= {ts'2003-09-02 17:01:09'}
    

    我建议使用Optimizer. sp_optimizefullsync All

    请参阅:如何设置 QODBC 优化器以及优化器选项在哪里,以了解有关优化器的所有详细信息。 (http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2358/48/how-to-setup-qodbc-optimizer-and-where-are-the-optimizer-options)

      By default the optimizer will update new and changed entries in a table from QuickBooks first and then execute the query against the local optimized table. This is faster than reading everything out of QuickBooks every time, especially the more data you have. 
    

    【讨论】:

      【解决方案2】:

      没用过这个驱动,试试这个:

      SELECT * FROM Invoice WHERE TimeCreated > {d'2014-01-01 00:00:00.000'}

      可能需要稍微修改一下日期字符串的格式,只是猜测。

      就您的选择速度而言,如果查询具有 WHERE 子句,则可能会因表上没有索引而受到影响。有索引的表会比没有索引的表更快地返回结果。

      【讨论】:

      • 是的,没有骰子。也许在报告本身完成之后,我会担心一个适当的陈述。现在,我只是拉出所有行并在我的脚本中剔除我需要的内容。可怕,但它完成了工作。是的。我知道索引字段,但是,1)我不知道 quickbooks 索引了什么(我想它会足够智能来索引它用来引用其他表的字段)和 2)我不认为我能够添加我自己的索引.不过感谢您的回答! =)
      • 据我所知,QODBC驱动实际上是使用QuickBooks SDK来执行查询,并没有直接连接到数据库,影响速度。
      • 好的。我想通了。 @布鲁斯路德。这将是答案......如果 TimeCreated 是一个日期字段。原来我已经被 MySQL 宠坏了。 TimeCreated 实际上是一个时间戳,所以查询应该是{ts'2014-01-01 00:00:00'}。还有@Hpjchobbes,这很有趣!我还必须研究使用 SDK 需要什么。也许这会有所帮助。
      猜你喜欢
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-04
      • 2018-09-14
      • 1970-01-01
      相关资源
      最近更新 更多