关于存储过程的编写问题

关于存储过程的编写问题

[ 本帖最后由 kimjhj 于 2008-8-15 23:24 编辑 ]
我也来说两句 查看全部回复

最新回复

  • yanbasin (2008-8-12 14:23:02)

    用job定时执行
    或者操作系统级的计划任务(windows)\ cron(linux)
  • wwwzq55888cn (2008-8-12 21:49:06)

    皇冠平台出租   http://www.zq666888.cn

    皇冠开户  http://www.zq3668.cn

    皇冠足球网  http://www.zq333.cn

    皇冠足球开户 http://www.ao3888.cn

    六?彩平台修改  http://www.zq55888.cn
  • nemo410 (2008-8-13 10:57:16)

    procedure P_Test is

        n_quantity   drug_stock.quantity%type;
        cnt          number(2);
        e_too_many   exception;
       
        cursor c is
        select m.code,m.storage,m.quantity
          from (
                        select distinct a.code,a.storage,a.quantity,b.form,b.class
                          from drug_stock a ,drug_collate b
                         where a.code=b.code
                       ) m
         where exists (
                        select * from (
                                       select distinct a.code,a.storage,a.quantity,b.form,b.class
                                                  from drug_stock a ,drug_collate b
                                                 where a.code=b.code) n
                                        where m.code=n.code
                                          and m.storage=n.storage
                                          and m.form=n.form
                                          and m.quantity<>n.quantity
                        )
           and m.quantity<0;
          
    begin
        for r in c loop
            select sum(quantity)
              into n_quantity
              from drug_stock
             where code=r.code
               and storage=r.storage;
               
            select count(*)
              into cnt
              from drug_stock
             where code=r.code
               and storage=r.storage
               and quantity>=0;
            
            if cnt>1 then
               raise e_too_many;
            end if;
            
            update drug_stock
               set quanqity=n_quantity  
             where code=r.code
               and storage=r.storage
               and quantity>=0;
               
            update drug_stock
               set quanqity=0
             where code=r.code
               and storage=r.storage
               and quantity<0;
        end loop;
    exception
           when e_too_many then
                message('too many rows (quantity>0)');
           when others then
                message('unknow error');
    end;

    如果测试成功,就可以用oracle job 或是写成批处理后用windows 任务计划进行定时執行
  • kimjhj (2008-8-13 22:32:32)

    谢谢,我试下