When trying to run this query on cx_Oracle in python
Insert into orange.cp4_freeze_tasks (
SELECT distinct cust_id, 'C'
FROM (SELECT f.cust_id, cust_site, debt_invoiced + debt_no_invoiced deuda,
DECODE (d.manual_level, 0, cp_level, manual_level) nivel,
(SELECT nvl(freeze_limit,9999999999)
FROM orange.cp4_level_config
WHERE site_id = cust_site
AND cplevel =
DECODE (d.manual_level,0, cp_level,manual_level)) freeze_limit
FROM orange.cp4_freezed_customers f, orange.cp4_debt_status d
WHERE f.cust_id = d.cust_id) c
WHERE deuda <= freeze_limit / 2 and not exists (Select 1 from orange.cp4_freeze_tasks
where cust_id = c.cust_id and task_status = 'C'));commit;
I'm receiving the following error:
cx_Oracle.DatabaseError: ORA-00911: invalid character
Already tried the solution from other questions: Deleting the last semicolon.
Any idea how to solve it?
Going to guess it's this that's causing the problem:
where cust_id = c.cust_id and task_status = 'C'));commit;
You've got two SQL statements in the one query. Remove the ;commit;
. Your insert statement should now work. Change your python and add this after you run the insert:
connection.commit()
Obviously change connection
to fit the actual variable name you use.