<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    heting

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      40 隨筆 :: 9 文章 :: 45 評論 :: 0 Trackbacks
    drop procedure if exists pro_rep_shadow_rs;   
    delimiter 
    |   
    ----------------------------------   
    --
     rep_shadow_rs   
    --
     用來處理信息的增加,更新和刪除   
    --
     每次只更新上次以來沒有做過的數據   
    --
     根據不同的標志位   
    --
     需要一個輸出的參數,   
    --
     如果返回為0,則調用失敗,事務回滾   
    --
     如果返回為1,調用成功,事務提交   
    --
       
    --
     測試方法   
    --
     call pro_rep_shadow_rs(@rtn);   
    --
     select @rtn;   
    --
    --------------------------------   
    create procedure pro_rep_shadow_rs(out rtn int)   
    begin   
        
    -- 聲明變量,所有的聲明必須在非聲明的語句前面   
        declare iLast_rep_sync_id int default -1;   
        
    declare iMax_rep_sync_id int default -1;   
        
    -- 如果出現異常,或自動處理并rollback,但不再通知調用方了   
        -- 如果希望應用獲得異常,需要將下面這一句,以及啟動事務和提交事務的語句全部去掉   
        declare exit handler for sqlexception rollback;   
        
    -- 查找上一次的   
        select eid into iLast_rep_sync_id from rep_de_proc_log where tbl='rep_shadow_rs';   
        
    -- 如果不存在,則增加一行   
        if iLast_rep_sync_id=-1 then   
          
    insert into rep_de_proc_log(rid,eid,tbl) values(0,0,'rep_shadow_rs');   
          
    set iLast_rep_sync_id = 0;   
        
    end if;   
           
        
    -- 下一個數字   
        set iLast_rep_sync_id=iLast_rep_sync_id+1;   
        
    -- 設置默認的返回值為0:失敗   
        set rtn=0;   
           
        
    -- 啟動事務   
        start transaction;   
        
    -- 查找最大編號   
        select max(rep_sync_id) into iMax_rep_sync_id from rep_shadow_rs;   
        
    -- 有新數據   
        if iMax_rep_sync_id>=iLast_rep_sync_id then   
            
    -- 調用   
            call pro_rep_shadow_rs_do(iLast_rep_sync_id,iMax_rep_sync_id);   
            
    -- 更新日志   
            update rep_de_proc_log set rid=iLast_rep_sync_id,eid=iMax_rep_sync_id where tbl='rep_shadow_rs';   
        
    end if;   
           
        
    -- 運行沒有異常,提交事務   
        commit;   
        
    -- 設置返回值為1  
        set rtn=1;   
    end;   
    |   
    delimiter ;   
    drop procedure if exists pro_rep_shadow_rs_do;   
    delimiter 
    |   
    ---------------------------------   
    --
     處理指定編號范圍內的數據   
    --
     需要輸入2個參數   
    --
     last_rep_sync_id 是編號的最小值   
    --
     max_rep_sync_id 是編號的最大值   
    --
     無返回值   
    --
    -------------------------------   
    create procedure pro_rep_shadow_rs_do(last_rep_sync_id int, max_rep_sync_id int)   
    begin   
        
    declare iRep_operationtype varchar(1);   
        
    declare iRep_status varchar(1);   
        
    declare iRep_Sync_id int;   
        
    declare iId int;   
        
    -- 這個用于處理游標到達最后一行的情況   
        declare stop int default 0;   
        
    -- 聲明游標   
        declare cur cursor for select id,Rep_operationtype,iRep_status,rep_sync_id from rep_shadow_rs where rep_sync_id between last_rep_sync_id and max_rep_sync_id;   
        
    -- 聲明游標的異常處理,設置一個終止標記   
        declare CONTINUE HANDLER FOR SQLSTATE '02000' SET stop=1;   
           
        
    -- 打開游標   
        open cur;   
           
        
    -- 讀取一行數據到變量   
        fetch cur into iId,iRep_operationtype,iRep_status,iRep_Sync_id;   
        
    -- 這個就是判斷是否游標已經到達了最后   
        while stop <> 1 do  
            
    -- 各種判斷   
            if iRep_operationtype='I' then   
                
    insert into rs0811 (id,fnbm) select id,fnbm from rep_shadow_rs where rep_sync_id=iRep_sync_id;   
            elseif iRep_operationtype
    ='U' then   
            
    begin   
                
    if iRep_status='A' then   
                    
    insert into rs0811 (id,fnbm) select id,fnbm from rep_shadow_rs where rep_sync_id=iRep_sync_id;   
                elseif iRep_status
    ='B' then   
                    
    delete from rs0811 where id=iId;   
                
    end if;   
            
    end;   
            elseif iRep_operationtype
    ='D' then   
                
    delete from rs0811 where id=iId;   
            
    end if;    
               
            
    -- 讀取下一行的數據    
            fetch cur into iId,iRep_operationtype,iRep_status,iRep_Sync_id;   
        
    end while;  -- 循環結束   
        close cur; -- 關閉游標   
     end;   
    posted on 2009-03-25 09:55 賀挺 閱讀(533) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 天天拍拍天天爽免费视频| 国产精品免费无遮挡无码永久视频| 亚洲成Av人片乱码色午夜| 亚洲视频在线观看视频| 久久狠狠躁免费观看| 亚洲成AV人片在| 久久不见久久见免费视频7| 久久亚洲免费视频| 99久久99热精品免费观看国产| 亚洲专区在线视频| 美女视频黄a视频全免费| 2020亚洲男人天堂精品| 日本成人免费在线| 亚洲欧洲精品视频在线观看| 久久99国产综合精品免费| 亚洲国语在线视频手机在线| 免费无码又爽又刺激高潮| 日本在线观看免费高清| 成年男女免费视频网站| 亚洲砖码砖专无区2023| 高清在线亚洲精品国产二区| 亚洲黄色激情视频| 免费乱理伦在线播放| aaa毛片免费观看| 亚洲乱码国产一区网址| 久久久久久久久久国产精品免费 | 高清在线亚洲精品国产二区| 国产精品1024在线永久免费| 亚洲a在线视频视频| 国产无人区码卡二卡三卡免费| 最新亚洲人成网站在线观看| 日韩亚洲欧洲在线com91tv| 日本人的色道免费网站| 男人j进女人p免费视频| 亚洲视频在线观看一区| 国产成人免费一区二区三区| 黄网站色视频免费在线观看的a站最新 | 日韩精品成人无码专区免费| 久久99亚洲网美利坚合众国| 免费看大黄高清网站视频在线| 国产精品综合专区中文字幕免费播放 |