Closed jam21 closed 3 years ago
I do not know what was the issue but we fixed it making changes in my SQL query
I replaced
if trunc(p_order_date) < '11-FEB-2021' then ......... ......... endif
with
if trunc(p_order_date) < to_date('11-FEB-2021','DD-MON-RRRR') then ............. ............. endif
and it fixed now
This is unrelated to cx_Oracle, but Django's own logic. Django executes in every database connection:
ALTER SESSION SET
NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'
NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'
This issue can be closed.
Ok. Thanks for following up!
I executed the following query from my Django project shell.
from django.db import connection balance_query = "some sql query here" with connection.cursor() as cur: cur.execute(balance_query) balance_data = cur.fetchall() print(balance_date)
Then I get result after print as (1, 'F', 77259668) (9, 'R', '24153')
The bold value is wrong
But When I execute same query with following code
import cx_Oracle dsn_tns = cx_Oracle.makedsn('host', 'post', service_name='name') conn = cx_Oracle.connect(user=r'user', password='pwd', dsn=dsn_tns) c = conn.cursor() c.execute(balance_query) for r in c: print(r)
Then it shows correct values which are following(1, 'F', '77244730') (9, 'R', '24153')
Only one value is differentiating which I marked bold and italic Backend. DB is Oracle and I am using same instance with same credentials for both connections. It is only happening for one user, for all other users query gives same result with cx_oracle and django.connection.cursor