CREATE PROCEDURE [dbo]. [Rau_CreateMission_Group] @flag bit, @ starttime datetime ASdeclare @caller varchar (20) declare @callee varchar (20) declare @callergroup intdeclare @calleegroup intDECLARE phone_cur CURSOR FORselect 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_idand A.Group_ID in (SELECT * from groupbuff) and b.Group_id in (SELECT * from groupbuff) Order by a.iddelete from missionbuffopen phone_curfetch next from phone_curinto @ Caller, @ Callergroup, @ Callee, @ CalleeGroupWhile @@ fetch_status = 0begin
if @flag = 0begininsert into missionbuff (caller, callergroup, callee, calleegroup) values (@ caller, @ callergroup, @ callee, @ calleegroup) endelsebegininsert into missionbuff (caller, callergroup, callee, calleegroup, starttime) values (@ caller, @ Callergroup, @ Callee, @ CalleeGroup, @ StartTime) End
Fetch next from phone_curinto @ Caller, @ Callergroup, @ Callee, @ CalleeGroupendClose Phone_Curdeallocate Phone_curgo