Re: ORA-01790 error on union all with nullable bind variables

"Massa, Harald Armin" <[email protected]> Mon, 18 Apr 2016 10:04:18 +0200
Newsgroups gmane.comp.python.db.cx-oracle
Message-ID <CAMSP2L7rmfdNorhEwk5RipS2GSYZ4UmzBp8C55TA=xZmmW3YyA@mail.gmail.com>
>
>
> Does anybody know why this query fails with ORA-01790?
>
> ```
> >>> import cx_Oracle
> >>> con = cx_Oracle.connect('django/[email protected]/orcl')
> >>> cur = con.cursor()
> >>> cur.execute('SELECT 1 FROM dual UNION ALL SELECT :arg0 FROM dual',
> arg0=None)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> cx_Oracle.DatabaseError: ORA-01790: expression must have same datatype
> as corresponding expression
> ```
>
> It seems to me that bind variables passes as empty string '' and not as
> NULL value.
>

most likely it is connected with this:

http://stackoverflow.com/questions/13278773/null-vs-empty-string-in-oracle

empty varchar2 and NULL being treated as equal in Oracle.

so, my suggestion, in the select :arg0 from dual cast :argo as numeric.

Harald

-- 

GHUM GmbH
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607

Amtsgericht Stuttgart, HRB 734971

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

_______________________________________________
cx-oracle-users mailing list
cx-oracle-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/cx-oracle-users