declare my_cursor cursor scroll
for
select pf_id,BedshaftMeter,WatchSpindleMeter,result from UDT_PaperFault where event_num = @event_num
open my_cursor
fetch next from my_cursor into @pf_id,@BedshaftMeter,@WatchSpindleMeter,@result
while(@@fetch_status=0)
begin
if(@result='True' or @result='true')
begin
declare @SUMMeter float
declare @numTempB float
declare @numTempW float
select @SUMMeter = isnull(convert(decimal(18,0),result),0) from v_prod_eventAndresult where event_id = @event_id
set @numTempB = @SUMMeter - convert(decimal(18,0),@WatchSpindleMeter)
set @numTempW = @SUMMeter - convert(decimal(18,0),@BedshaftMeter)
set @BedshaftMeter = @numTempB
set @WatchSpindleMeter =@numTempW
update udt_paperfault set BedshaftMeter=@BedshaftMeter,WatchSpindleMeter=@WatchSpindleMeter,result='BTrue'
where pf_id = @pf_id
end
fetch next from my_cursor into @pf_id,@BedshaftMeter,@WatchSpindleMeter,@result
end
fetch first from my_cursor into @pf_id,@BedshaftMeter,@WatchSpindleMeter,@result
close my_cursor
deallocate my_cursor