编写存储过程保存为 .sql 文件运行,生成按季度分类的汇总销售额报表,包括:季度(标题)、年度、订单数、销售额用逻辑循环编,要怎么写啊

解决方案 »

  1.   


    create or replace prosale(v_year number,v_quarter number)
    is
    begin
        insert into desTab(year,quarter,indents,money)
        select to_number(to_char(trade_date,'yyyy'),9999),to_number(to_char(trade_date,'Q')) as       quarter,count(*) from tab where to_number(to_char(trade_date,'yyyy'),9999)=v_year and quarter=v_quarter;
    commit; 
    end
      

  2.   


    create or replace prosale(v_year number,v_quarter number)
    is
    begin
        insert into desTab(year,quarter,indents,money)
        select to_number(to_char(trade_date,'yyyy'),9999),to_number(to_char(trade_date,'Q')) as       quarter,count(*),sum(trade_amount) from tab where to_number(to_char(trade_date,'yyyy'),9999)=v_year and quarter=v_quarter;
    commit; 
    end
      

  3.   

    create or replace procedure quraur
    is
    cursor_1 CURSOR IS select to_char(o.OrderDate,'q') as quarter , to_char(o.OrderDate,'yyyy')  AS year ,sum(s.Price * s.Num * ( 1-s.Disconut ) ) as sale from SaleOrderItem s , Orders o  where  s.OrderID=o.OrdersID group by to_char(o.OrderDate,'q'), to_char(o.OrderDate,'yyyy');
    oq  Orders.quarter%type;
    ye  Orders.year%type;
    sa  SaleOrderItem.sale%number;
    begin
    open cursor_1;
      loop
        fetch cursor_1 into oq,ye,sa; 
        exit when cursor_1%notfound;
         if cursor_1%found then
          dbms_output.put_line(oq||' '||ye||' '||sa);
         end if;
      end loop;
    close cursor_1;
    end; error
    3/17     PLS-00103: 出现符号 "IS"在需要下列之一时:
             := . ( @ % ;
             not null range default character17/4     PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
             pragma这个错误是怎么回事啊
      

  4.   

    咋还没结贴呢
    http://topic.csdn.net/u/20110927/15/6b3fc3cf-e9a6-4cc2-8e5a-232596f5a38b.html