Jody

 

CREATE PROCEDURE

CREATE PROCEDURE birdincome_zf
AS
declare @actionid integer
declare @mid varchar(100)
declare @service_id varchar(100)

declare  case1    cursor for 
    SELECT mid,service_id from bird_user_2006_03 where type=0 
declare  case2    cursor for 
    SELECT mid,service_id from bird_user_2006_03 where type=1
 
open case1
  fetch next from case1 into @mid,@service_id
  while (@@fetch_status=0)
    begin
        select top 1  @actionid=bb.actionid from  operation_temp_0526 as bb
               where bb.serviceid=@service_id and bb.mid=@mid
        order by bb.id desc

     if (@actionid=1)        
        insert into bird_user_2006_04(mid,service_id,type,portal_id) values(@mid,@service_id,'1','10000')
     else
         print 'ooooooo'     
        fetch next from case1 into @mid,@service_id
   end
deallocate case1

open case2
  fetch next from case2 into @mid,@service_id
  while (@@fetch_status=0)
    begin
        select  top 1 @actionid=bb.actionid from  operation_temp_0526 as bb
               where bb.serviceid=@service_id and bb.mid=@mid
        order by bb.id desc

     if (@actionid != 2)          
        insert into bird_user_2006_04(mid,service_id,type,portal_id) values(@mid,@service_id,'2','10000')
        fetch next from case2 into @mid,@service_id
   end
deallocate case2
GO

posted on 2006-05-29 13:24 zhaofei1394 阅读(628) 评论(0)  编辑  收藏 所属分类: SQL Server


只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问  
 

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

友情链接

搜索

最新评论

阅读排行榜

评论排行榜