尝试将优化的SQL执行计划加载到计划表中时接收ORA 00907

时间:2016-12-13 12:49:25

标签: sql oracle sql-execution-plan sql-optimization

将SQL计划加载到计划表时收到错误。谁能帮我? 这是我的代码:

APPS@PROD1> @xplan.sql
          ((t2.productgroup_id = 15520)   AND  (t1.productgroup_id = 15520) /*
                               *
ERROR at line 22:
ORA-00907: missing right parenthesis


APPS@PROD1> host cat xplan.sql
    explain plan into

plan_table
for
SELECT /* ORDERED INDEX(t1) USE_HASH(t1) */     'B' || 
          t2.pg_featurevalue_13_id pg_featurevalue_13_id,     'B' || 
          t2.pg_featurevalue_02_id pg_featurevalue_02_id,     'r' || 
          t4.elementrange_id pg_featurevalue_15_id,     'B' || 
          t2.pg_featurevalue_08_id pg_featurevalue_08_id,     'B' || 
          t2.pg_featurevalue_01_id pg_featurevalue_01_id,     'r' || 
          t5.elementrange_id price_eur_id,     'B' || t2.productgroup_id 
          productgroup_id,     'G' || t6.elementgroup_id period_id,     
          SUM(t1.pd_sales_units*t1.pd_projection_factor*t1.pd_price_units_eur) 
          salesvalueeur FROM     lu_item_293 t2,     lu_pg_featurevalue_15 t3,    
           lu_elementrange_rel t4,     fact_pd_out_itm_293 t1,     
          lu_elementgroup_rel t6,     lu_elementrange_rel t5 WHERE /* Attribute 
          Joins */       ((t1.item_id = t2.item_id /* Customizing Begin */   AND  
           t1.productgroup_id = t2.productgroup_id) /* Customizing End */   AND  
          (t2.pg_featurevalue_15_id = t3.pg_featurevalue_15_id)   AND  
          (t3.pg_featurevalue_15_num BETWEEN t4.lbound AND t4.ubound)   AND  
          (t1.pd_price_units_eur BETWEEN t5.lbound AND t5.ubound)   AND  
          (t1.period_id = t6.value_id)       ) /* Attribute Filters */   AND 
          ((t2.productgroup_id = 15520)   AND  (t1.productgroup_id = 15520) /* 
          Push Down Filters */   AND  (t2.pg_featurevalue_01_id IN 
          (103,104,107,110,113,134,148,167,171,186,192,216,2259,236,241,2477,24958
          ,27445,297,3891,71,76,89,92,95))   AND  (t2.pg_featurevalue_08_id IN 
          (716,717))   AND  (t2.pg_featurevalue_02_id IN (4165,4166))   AND  
          (t2.pg_featurevalue_13_id = 5424)   AND  (t4.elementrange_id IN 
          (3091,3092))   AND  (t5.elementrange_id IN 
          (8658,8659,8660,8661,8662,8663,8664))   AND  (t6.elementgroup_id = 
          14659)   AND  (t1.period_id IN (20030699999060,20030799999030,2003079999
          9060,20030799999120)) /* Resolved ElementGroup Filters */       ) /* 
          Fact Filters */   AND (t1.project_type_id = '1'       ) GROUP BY     
          t2.pg_featurevalue_13_id,     t2.pg_featurevalue_02_id,     
          t4.elementrange_id,     t2.pg_featurevalue_08_id,     
          t2.pg_featurevalue_01_id,     t5.elementrange_id,     
          t2.productgroup_id,     t6.elementgroup_id;

APPS@PROD1> 

没有任何括号问题,因为我从Oracle EM复制粘贴了select语句。 我听说过使用set linesize更改sql_txt列,因为在命令行的默认模式下,v $ sql无法捕获所有sql_txt,因为sqls语句太长。但我不确切知道如何改变它,有人可以帮助我吗?非常感谢!

1 个答案:

答案 0 :(得分:0)

重新组织查询后,我注意到您的某个数字序列中有换行符和空格,请尝试以下重新格式化的查询:

SELECT /* ORDERED INDEX(t1) USE_HASH(t1) */     
     'B' || t2.pg_featurevalue_13_id pg_featurevalue_13_id,
     'B' || t2.pg_featurevalue_02_id pg_featurevalue_02_id,
     'r' || t4.elementrange_id pg_featurevalue_15_id,
     'B' || t2.pg_featurevalue_08_id pg_featurevalue_08_id,
     'B' || t2.pg_featurevalue_01_id pg_featurevalue_01_id,
     'r' || t5.elementrange_id price_eur_id,
     'B' || t2.productgroup_id productgroup_id,
     'G' || t6.elementgroup_id period_id,     
     SUM(t1.pd_sales_units*t1.pd_projection_factor*t1.pd_price_units_eur) salesvalueeur 
FROM lu_item_293 t2,
     lu_pg_featurevalue_15 t3,    
     lu_elementrange_rel t4,
     fact_pd_out_itm_293 t1,     
     lu_elementgroup_rel t6,
     lu_elementrange_rel t5 
WHERE       
    ((t1.item_id = t2.item_id 
     AND t1.productgroup_id = t2.productgroup_id) 
     AND (t2.pg_featurevalue_15_id = t3.pg_featurevalue_15_id)
     AND (t3.pg_featurevalue_15_num BETWEEN t4.lbound AND t4.ubound)
     AND (t1.pd_price_units_eur BETWEEN t5.lbound AND t5.ubound)
     AND (t1.period_id = t6.value_id)
    )
    AND 
    ((t2.productgroup_id = 15520)   
     AND  (t1.productgroup_id = 15520)
     AND (t2.pg_featurevalue_01_id IN 
          (103,104,107,110,113,134,148,167,171,186,192,216,2259,236,241,2477,24958
          ,27445,297,3891,71,76,89,92,95))   
     AND (t2.pg_featurevalue_08_id IN 
          (716,717))   
     AND (t2.pg_featurevalue_02_id IN (4165,4166))   
     AND (t2.pg_featurevalue_13_id = 5424)   
     AND (t4.elementrange_id IN (3091,3092))   
     AND (t5.elementrange_id IN (8658,8659,8660,8661,8662,8663,8664))   
     AND (t6.elementgroup_id = 14659)   
     AND (t1.period_id IN (20030699999060,20030799999030,20030799999060,20030799999120))       
    )
    AND (t1.project_type_id = '1') 
    GROUP BY t2.pg_featurevalue_13_id,     
        t2.pg_featurevalue_02_id,     
        t4.elementrange_id,     
        t2.pg_featurevalue_08_id,     
        t2.pg_featurevalue_01_id,     
        t5.elementrange_id,     
        t2.productgroup_id,     
        t6.elementgroup_id;