google-code-export / ibm-db

Automatically exported from code.google.com/p/ibm-db
1 stars 0 forks source link

SQL syntax error SQLCODE=-180 visible on fetch instead of execute #159

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
   The following query will reveal a syntax error when trying to fetch rows, dates in query are missing seconds component.

    >>> cursor.execute("SELECT message FROM t1 WHERE col1 BETWEEN '2014-06-16 12:20' AND '2014-06-20 00:00'")
    True
    >>> rs = cursor.fetchall()
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/radsight/lib/python/database.py", line 636, in fetch_all
        result = orig_fetchall(self) 
    File "/usr/local/lib64/python2.6/site-packages/ibm_db-2.0.4.1-py2.6-linux-x86_64-SP3.egg/ibm_db_dbi.py", line 1457, in fetchall
        return self._fetch_helper()
    File "/usr/local/lib64/python2.6/site-packages/ibm_db-2.0.4.1-py2.6-linux-x86_64-SP3.egg/ibm_db_dbi.py", line 1414, in _fetch_helper
        raise self.messages[len(self.messages) - 1]
    ibm_db_dbi.DataError: ibm_db_dbi::DataError: Fetch Failure: [IBM][CLI Driver][DB2/LINUXX8664] SQL0180N  The syntax of the string representation of a datetime value is incorrect.  SQLSTATE=22007 SQLCODE=-180

What is the expected output? What do you see instead?

    I would expect cursor.execute to return False. Also, exception type ibm_db_dbi::DataError seems misleading and ibm_db_dbi::ProgrammingError should be thrown instead.
    if date is fixed query works as expected.

What version of the product are you using? On what operating system?

    ibm_db-2.0.4.1-py2.6-linux-x86_64
    Suse enterprise 11 SP3 X86_64

Original issue reported on code.google.com by south.mi...@gmail.com on 11 Jul 2014 at 6:56