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

receiving ORA 00907 while trying to load optimized SQL execution Plan into plan table

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

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,因为 sql的声明太长了。但是我不知道具体怎么改,谁能帮帮我?非常感谢!

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

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;