create or replace procedure test000(I_FUNDCODE varchar2(10),I_PROVINCE varchar2(10),RT_CURSOR out sys_refcursor) is
begin
open RT_CURSOR for select PV.NAME, PS.FUNDNAME,
                              count(case when ct.age between 1 and 20 then 1 else null end) "1~20岁",
                              count(case when ct.age between 21 and 40 then 1 else null end) "21~40岁",
                              count(case when ct.age > 41 then 1 else null end) "41岁以上",
                              sum(ts.curshare)
                              from CUSTOMERS ct, PROVINCE pv, TA_SHARE ts, PRODUCTS1 ps
                              where pv.id = ct.province
                              and ct.taaccoid = TS.TAACCOID
                              and TS.FUNDCODE = I_FUNDCODE
                              and pv.name=I_PROVINCE
                              group by PV.NAME, PS.FUNDNAME
                              order by 1, 2;
end;

解决方案 »

  1.   

    create or replace procedure test000(I_FUNDCODE varchar2,I_PROVINCE varchar2,RT_CURSOR out sys_refcursor) is
    begin
    open RT_CURSOR for select PV.NAME, PS.FUNDNAME,
      count(case when ct.age between 1 and 20 then 1 else null end) "1~20岁",
      count(case when ct.age between 21 and 40 then 1 else null end) "21~40岁",
      count(case when ct.age > 41 then 1 else null end) "41岁以上",
      sum(ts.curshare)
      from CUSTOMERS ct, PROVINCE pv, TA_SHARE ts, PRODUCTS1 ps
      where pv.id = ct.province
      and ct.taaccoid = TS.TAACCOID
      and TS.FUNDCODE = I_FUNDCODE
      and pv.name=I_PROVINCE
      group by PV.NAME, PS.FUNDNAME
      order by 1, 2;
    end;
      

  2.   

    你最好把具体错误说一下,才能帮你解决。我看到你的“存储过成参数”如:I_FUNDCODE varchar2(10)  参数的数据类型不需要加精度,并且需要指定是输入参数还是输出参数。我帮你修改一下,你试一试,有问题把具体错误信息发出来:create or replace procedure test000(I_FUNDCODE in varchar2,I_PROVINCE in varchar2,RT_CURSOR out sys_refcursor) is
    begin
    open RT_CURSOR for select PV.NAME, PS.FUNDNAME,
      count(case when ct.age between 1 and 20 then 1 else null end) "1~20岁",
      count(case when ct.age between 21 and 40 then 1 else null end) "21~40岁",
      count(case when ct.age > 41 then 1 else null end) "41岁以上",
      sum(ts.curshare)
      from CUSTOMERS ct, PROVINCE pv, TA_SHARE ts, PRODUCTS1 ps
      where pv.id = ct.province
      and ct.taaccoid = TS.TAACCOID
      and TS.FUNDCODE = I_FUNDCODE
      and pv.name=I_PROVINCE
      group by PV.NAME, PS.FUNDNAME
      order by 1, 2;
    end;