由于我只有查询权限。然后写的报表维度很多。
只能很对union all连接起来 然后再做查询。
最终的sql如下面示意:
select *
from 
( select a,a1 from aa where date>=to_date('2012-09-01','YYYY-MM-DD')
union all
  select b,b1 from bb where date>=to_date('2012-09-01','YYYY-MM-DD')
union all
  select c,c1 from cc where date>=to_date('2012-09-01','YYYY-MM-DD')
) c每次取数,修改里面的时间很麻烦。请问 oracle里面能实现
我在开头设定一个参数
然后设置了这个参数,传给sql,返回查询结果。

解决方案 »

  1.   

    我用的是pl/sql developer开发的
      

  2.   

    &这个符号可以传递参数。要不写成存储过程或者块吧
      

  3.   

    select *
    from 
    ( select empno,ename from emp where hiredate>=to_date(&&date,'YYYY-MM-DD')
    union all
      select empno,ename from emp where hiredate>=to_date(&&date,'YYYY-MM-DD')
    union all
      select empno,ename from emp where hiredate>=to_date(&&date,'YYYY-MM-DD')
    ) c运行时会提示你输入date的值,比如输入(注意带上前后单引号):'2012-01-01'
    如果要在一次连接中多次运行,运行前先执行下:
    undefine date;
      

  4.   

    用PL/SQL 匿名块+绑定变量就可以搞定
      

  5.   

    用参数,下面例子你看下就懂了,PL/SQL命令行执行:undefine x;
    select * from myoracle a where a.id>&&x;提示信息:“输入值于x:”,输入即可。
    http://t.cn/zWeWwxA
      

  6.   


    define x '2012-09-01'
    select &&x, to_date(&&x, 'yyyymmdd) from dual;