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 閱讀(635) 評論(0) 編輯 收藏 所屬分類: SQL Server