Skip to content

Problem empty date cause ValueError: year -9999 is out of range #347

@doudz

Description

@doudz

I'm using cx_Oracle 7.2.2 with Oracle instant client 11.2.0.4 on a Oracle 10g database.
I'm running Ubuntu 18.04 LTS with Python 3.6 (tried Python 3.7 with the same result)
Everything is fine except when I tried to retrieve empty date

Example using sqlplus :

SQL> SELECT T$EMNO,T$EDTE,to_char(T$EDTE,'YYYY-MM-DD') FROM BAANDB.TTCCOM001300 WHERE T$EMNO=255;

    T$EMNO T$EDTE   TO_CHAR(T$EDTE,'YYYY-MM-DD')
---------- -------- ------------------------------
       255 01/01/99 0000-00-00

Same example using cx_Oracle

In [7]: cursor.execute("SELECT T$EMNO,T$EDTE,to_char(T$EDTE,'YYYY-MM-DD') FROM BAANDB.TTCCOM001300 WHERE T$EMNO=255")
Out[7]: <cx_Oracle.Cursor on <cx_Oracle.Connection to baandb@tbaan>>

In [8]: cursor.fetchone()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-8-5bbb96413e0a> in <module>()
----> 1 cursor.fetchone()

ValueError: year -9999 is out of range

On the same database, if I use cx_Oracle 5.2.1 and Oracle Instant client 10.2 with older python 3.5 it was working but I think it was a python bug as said here #166

Is there a way to configure cx_Oracle or instant client to convert such date to None or other working value ?
I can't upgrade the database itself because it's used by an ERP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions