if exists(select id from sysobjects where name='PSys_CheckIsHasNewCheckList')
drop proc dbo.PSys_CheckIsHasNewCheckList
go
create proc dbo.PSys_CheckIsHasNewCheckList
@CheckMan varchar(20)
as
declare @FormID int,@ListID varchar(60),@IsOK bit,@MAutoID int if exists(select top 1 autoid from TSys_ForCheckListTable where ToUser=@CheckMan and IsRead=0)
begin
set @IsOK=0
select distinct(a.FormID) as FormID into #Temp_ForCheckList_FormID
from TSys_CheckFlowMaster a,TSys_ForCheckListTable b
where ToUser=@CheckMan and IsRead=0 and a.AutoID=b.MAutoID declare out_cur cursor for
select FormID from #Temp_ForCheckList_FormID
open out_cur
fetch next from out_cur into @FormID
while (@@fetch_status=0)and(@IsOK=0)
begin
--判断每个单据号是否存在
declare incur cursor for
select ListID
from TSys_ForCheckListTable a,TSys_CheckFlowMaster b
where a.MAutoID=b.AutoID and b.FormID=@FormID and a.ToUser=@CheckMan and a.IsRead=0
open incur
fetch next from incur into @ListID
open incur
while (@@fetch_status=0)and(@IsOK=0)
begin
--处理单据
。 fetch next from incur into @ListID
end
close incur
deallocate incur
fetch next from out_cur into @FormID
end
close out_cur
deallocate out_cur if @IsOk=1
select 'OK' as OK
end 运行过程时,提示以下信息:
================================================================================(所影响的行数为 2 行) 服务器: 消息 16905,级别 16,状态 1,过程 PSys_CheckIsHasNewCheckList,行 50
游标已打开。(所影响的行数为 1 行)
================================================================================
drop proc dbo.PSys_CheckIsHasNewCheckList
go
create proc dbo.PSys_CheckIsHasNewCheckList
@CheckMan varchar(20)
as
declare @FormID int,@ListID varchar(60),@IsOK bit,@MAutoID int if exists(select top 1 autoid from TSys_ForCheckListTable where ToUser=@CheckMan and IsRead=0)
begin
set @IsOK=0
select distinct(a.FormID) as FormID into #Temp_ForCheckList_FormID
from TSys_CheckFlowMaster a,TSys_ForCheckListTable b
where ToUser=@CheckMan and IsRead=0 and a.AutoID=b.MAutoID declare out_cur cursor for
select FormID from #Temp_ForCheckList_FormID
open out_cur
fetch next from out_cur into @FormID
while (@@fetch_status=0)and(@IsOK=0)
begin
--判断每个单据号是否存在
declare incur cursor for
select ListID
from TSys_ForCheckListTable a,TSys_CheckFlowMaster b
where a.MAutoID=b.AutoID and b.FormID=@FormID and a.ToUser=@CheckMan and a.IsRead=0
open incur
fetch next from incur into @ListID
open incur
while (@@fetch_status=0)and(@IsOK=0)
begin
--处理单据
。 fetch next from incur into @ListID
end
close incur
deallocate incur
fetch next from out_cur into @FormID
end
close out_cur
deallocate out_cur if @IsOk=1
select 'OK' as OK
end 运行过程时,提示以下信息:
================================================================================(所影响的行数为 2 行) 服务器: 消息 16905,级别 16,状态 1,过程 PSys_CheckIsHasNewCheckList,行 50
游标已打开。(所影响的行数为 1 行)
================================================================================
declare incur cursor for
select ListID
from TSys_ForCheckListTable a,TSys_CheckFlowMaster b
where a.MAutoID=b.AutoID and b.FormID=@FormID and a.ToUser=@CheckMan and a.IsRead=0
open incur
fetch next from incur into @ListID
/* open incur --上面已经OPEN了 */
while (@@fetch_status=0)and(@IsOK=0)
begin
--处理单据
。
declare incur cursor for
select ListID
from TSys_ForCheckListTable a,TSys_CheckFlowMaster b
where a.MAutoID=b.AutoID and b.FormID=@FormID and a.ToUser=@CheckMan and a.IsRead=0
open incur
fetch next from incur into @ListID
open incur
while (@@fetch_status=0)and(@IsOK=0)
begin
打开两次