if @varFlag in ('ALL','DEPT') begin if @varFlag='ALL' begin Declare crCreate1 cursor for Select MI02,MI03 from ATNMH INNER JOIN ATNMI ON ATNMH.MH01=ATNMI.MI01 Where (MI05='12:30' or MI07='12:30' or MI09='12:30') and MI03>=@curDateFirst and MI04<@curDateNext open crCreate1 fetch next from crCreate1 into @Id,@NewDate while @@fetch_status=0 begin Delete from ATNMD where MD01=@id and MD02=@NeWdate and MD03='13:30' Insert into ATNMD (MD01,MD02,MD03) values (@ID,@NewDate,'13:30') fetch next from crCreate1 into @Id,@NewDate end close crCreate1 deallocate crCreate1 end end
begin
if @varFlag='ALL'
begin
Declare crCreate1 cursor for
Select MI02,MI03 from ATNMH INNER JOIN ATNMI ON ATNMH.MH01=ATNMI.MI01
Where (MI05='12:30' or MI07='12:30' or MI09='12:30') and MI03>=@curDateFirst and MI04<@curDateNext
open crCreate1
fetch next from crCreate1 into @Id,@NewDate
while @@fetch_status=0
begin
Delete from ATNMD where MD01=@id and MD02=@NeWdate and MD03='13:30'
Insert into ATNMD (MD01,MD02,MD03) values (@ID,@NewDate,'13:30')
fetch next from crCreate1 into @Id,@NewDate
end
close crCreate1
deallocate crCreate1
end
end