0

我想知道是否可以将一个或多个参数传递给 WITH 子句查询;以一种非常简单的方式,做这样的事情(很明显,这是行不通的!):

with qq(a) as (
  select a+1 as increment 
    from dual
)
select qq.increment 
  from qq(10); -- should get 11

当然,我要做的使用要复杂得多,因为 with 子句应该在子查询中,而我要传递的参数是从主查询中获取的值......根据要求提供详细信息...... ;-)

感谢您的任何提示

4

1 回答 1

0

好的.....这是整个交易:

select appu.* from 
(<quite a complex query here>) appu
where not exists 
      (select 1 
             from dual 
             where appu.ORA_APP IN 
                   (select slot from 
                      (select distinct slots.inizio,slots.fine from 
                            (
                             with 
                             params as (select 1900 fine from dual)
                             --params as (select app.ora_fine_attivita fine 
                             -- where app.cod_agenda = appu.AGE
                             -- and app.ora_fine_attivita = appu.fine_fascia
                             --and app.data_appuntamento = appu.dataapp
                             --)
                             , 
                             Intervals (inizio, EDM) as
                             ( select 1700, 20 from dual
                             union all
                             select inizio+EDM, EDM from Intervals join params on 
                             (inizio <= fine)
                             )
                             select * from Intervals join params on (inizio <= fine)
                       ) slots
                    ) slots
        where slots.slot <= slots.fine
      )
      order by 1,2,3;

在不深入细节的情况下,where 条件应该删除那些“appu.ORA_APP”与应该在(外部)“slots”表中创建的记录之一匹配的记录。示例中使用的常量适用于记录子集(单个“appu.AGE”值),这就是为什么我应该对其进行参数化,以便使用注释的“参数”表(然后,在“间隔”表。

我知道从头开始分析并不容易,但我试图让它尽可能清晰;如果需要,请随时询问数字示例....谢谢

于 2016-11-24T13:12:45.420 回答