2

我有表 - FAKE_CUSTPRE_CUSTNORMAL_CUST。根据FAKE_CUST表中存在的约束,必须将值带到PRE_CUSTNORMAL_CUST

我正在使用以下代码:

INSERT ALL
         INTO PRE_CUST(CUST_ID, TOTAL_COST_TRANS) (SELECT DISTINCT CUST_ID,C FROM (
                    SELECT CUST_ID, SUM(COST_TRANS) OVER (PARTITION BY CUST_ID) as C FROM FAKE_CUST) WHERE C>1000)

         INTO NORMAL_CUST(CUST_ID, TOTAL_COST_TRANS) (SELECT DISTINCT CUST_ID,C FROM (
                    SELECT CUST_ID, SUM(COST_TRANS) OVER (PARTITION BY CUST_ID) as C FROM FAKE_CUST) WHERE C<1000)
SELECT 1 FROM DUAL;
4

1 回答 1

0

您用于多表插入的语法一开始就不正确。

WHEN评估插入条件的子句必须在子句之前insert_into

您的查询应如下所示:

INSERT ALL
   WHEN c > 1000 THEN
      INTO pre_cust (cust_id, total_cost_trans)
   WHEN c < 1000 THEN
      INTO normal_cust (cust_id, total_cost_trans)
   SELECT CUST_ID, SUM(COST_TRANS) OVER (PARTITION BY CUST_ID) as C 
   FROM   FAKE_CUST
于 2014-01-30T09:56:22.040 回答