0

尝试在 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

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

知道如何解决吗?

4

1 回答 1

3

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

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

您在一个查询中有两条 SQL 语句。删除;commit;. 您的插入语句现在应该可以工作了。运行插入后更改您的python并添加:

connection.commit()

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

于 2017-05-10T14:32:55.010 回答