为什么这个游标只能执行一次呢。。。。。
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
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
我这一句,我执行出来是四个记录,
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
但执行游标只能执行一次,
这是为什么呢。