错误:ORA-00911无效字符

时间:2017-05-10 14:24:20

标签: python database oracle cx-oracle ora-00911

尝试在python

中的cx_Oracle上运行此查询时
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;

我收到以下错误:

cx_Oracle.DatabaseError: ORA-00911: invalid character

已经尝试过其他问题的解决方案:删除最后一个分号。

知道怎么解决吗?

1 个答案:

答案 0 :(得分:3)

要猜测这是导致问题的原因:

where cust_id = c.cust_id and task_status = 'C'));commit;

您在一个查询中有两个SQL语句。删除;commit;。您的插入语句现在应该有效。更改你的python并在运行insert之后添加它:

connection.commit()

显然更改connection以适合您使用的实际变量名称。