@Examdate datetime,
@SceneNo varchar(40),
@EtsCode varchar(20),
@SubjectID varchar(40),
@SubjectName varchar(200)
AS
begin tran
declare @e1 as int,@e2 as int,@e3 as int
,@SceneID as int--本场在TExamScene中的流水号
,@StatusNo as int--本场第几次判分
select @SceneID=fSceneID from TExamScene where fEtsCode=@EtsCode and fExamPlaceID=@ExamPlaceID and fExamRoomID=@ExamRoomID and fExamdate=@Examdate and fSceneNo=@SceneNo
select @StatusNo=count(*)+1 from TStatResult where fSceneID=@SceneID
if @StatusNo>1
update TStatResult set fActiveFlag=0 where fSceneID=@SceneID and fSubjectID=@SubjectID
set @e1=@@error
insert into TStatResult (fSceneID,fStatusNo,fDogKey,fStatTime,fExamineeCount,fActiveFlag,fSubjectID,fSubjectName)
values (@SceneID,@StatusNo,@DogKey,getdate(),@ExamineeCount,0,@SubjectID,@SubjectName)
set @e2=@@error
--2006/08/08 begin
select @SceneID=fSceneID,@ExamineeCount=MAX(fExamineeCount) from TStatResult group by fSceneID
if @StatusNo>1
update TStatResult set fActiveFlag=1 where fSceneID=@SceneID and @ExamineeCount=fExamineeCount
set @e3=@@error
--2006/8/08 end
if @e1=0 and @e2=0 and @e3=0
begin
commit tran
return 0
end
else
begin
rollback tran
return -1
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
想达到 当同名的时候 显示ExamineeCount 最高的记录 并且给该记录 fActiveFlag 赋值为1