CSDN博客

img haroyy

Fetch例子

发表于2004/9/13 17:35:00  702人阅读

分类: DataBase

CREATE PROCEDURE [dbo].[Rau_CreateMission_Group]
@flag bit,
@starttime datetime
 AS
declare @caller varchar(20)
declare @callee varchar(20)
declare @callergroup int
declare @calleegroup int
DECLARE phone_cur CURSOR FOR
select a.phonenum caller,a.group_id callergroup,b.phonenum callee,b.group_id calleegroup from RAU_Phone a,RAU_Phone b
where a.id <> b.id and a.group_id <> b.group_id
and a.group_id in(select * from groupbuff) and b.group_id in(select * from groupbuff)
order by a.id
delete from missionbuff
OPEN phone_cur
FETCH NEXT FROM phone_cur
INTO @caller,@callergroup, @callee,@calleegroup
WHILE @@FETCH_STATUS = 0
BEGIN

if @flag = 0
begin
insert into missionbuff(caller,callergroup,callee,calleegroup) values(@caller,@callergroup,@callee,@calleegroup)
end
else
begin
insert into missionbuff(caller,callergroup,callee,calleegroup,starttime) values(@caller,@callergroup,@callee,@calleegroup,@starttime)
end

   FETCH NEXT FROM phone_cur
INTO @caller,@callergroup, @callee,@calleegroup
END
CLOSE phone_cur
DEALLOCATE phone_cur
GO

阅读全文
0 0

相关文章推荐

img
取 消
img