缺少右括号插入语句ORA-00907

时间:2014-11-24 05:29:57

标签: oracle

INSERT INTO packageamounts 
   SELECT 
       '6abc148c-20b7-cd34-c433-5472b1b9627d', packageamounts.name, '', '', 1, 1, 
       NULL, 0, NULL, packageamounts.package_id, '', packageamounts.amount, 
       packageamounts.taxtype_id, packageamounts.unit_value, 'd754c9c9-a0cb-ad43-b237-546c7f6eb903' 
   FROM 
       packageamounts 
   WHERE 
       packageamounts.id IN (SELECT id 
                             FROM (SELECT * 
                                   FROM packageamounts 
                                   WHERE packageamounts.insprovider_id = 'b7f4525a-0ddd-292a-a574-4d1c742e7ff8' 
                                   ORDER BY effective_date DESC ) AS v 
                             WHERE v.effective_date <= TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') 
                               AND v.deleted = 0  
                             ORDER BY v.effective_date DESC, v.date_entered DESC )  v 
   WHERE  v.deleted = 0 ORDER BY v.effective_date DESC, v.date_entered DESC);

1 个答案:

答案 0 :(得分:2)

试试这个:

INSERT INTO packageamounts 
   SELECT 
       '6abc148c-20b7-cd34-c433-5472b1b9627d', name, '', '', 1, 1, 
       NULL, 0, NULL, package_id, '', amount, 
       taxtype_id, unit_value, 'd754c9c9-a0cb-ad43-b237-546c7f6eb903' 
   FROM 
       packageamounts 
   WHERE 
       packageamounts.id IN (SELECT id 
                             FROM (SELECT * 
                                   FROM packageamounts 
                                   WHERE packageamounts.insprovider_id = 'b7f4525a-0ddd-292a-a574-4d1c742e7ff8' 
                                  ) AS v 
                             WHERE v.effective_date <= TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') 
                               AND v.deleted = 0) 
   and deleted = 0 
   ORDER BY effective_date DESC, date_entered DESC;

(删除了一些额外的ORDER BY +最后有一个额外的括号)

另一个同样的查询:

INSERT INTO packageamounts 
   SELECT 
       '6abc148c-20b7-cd34-c433-5472b1b9627d', name, '', '', 1, 1, 
       NULL, 0, NULL, package_id, '', amount, 
       taxtype_id, unit_value, 'd754c9c9-a0cb-ad43-b237-546c7f6eb903' 
   FROM 
       packageamounts 
   WHERE insprovider_id = 'b7f4525a-0ddd-292a-a574-4d1c742e7ff8' 
     and effective_date <= TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') 
     and deleted = 0
   ORDER BY effective_date DESC, date_entered DESC;