if (@OpMode = '1')
begin
if not exists (select 1 from dbo.OnLineOrder_CurrentTemp where OnLine_Process =@OnLine_Process)
begin
--print '1-I'
insert into dbo.OnLineOrder_CurrentTemp(EngineStreamNO, OnLine_Process, StartTime)
values (@EngineStreamNO, @OnLine_Process, getdate())
SELECT @intRowCount=@@ROWCOUNT,@intErrorCode=@@ERROR
IF @intErrorCode <> 0 OR @intRowCount != 1 GOTO ERROR1
end
else
begin
--print '1-U'
update dbo.OnLineOrder_CurrentTemp set EngineStreamNO =@EngineStreamNO,
StartTime=getdate()
where OnLine_Process =@OnLine_Process
IF @intErrorCode <> 0 OR @intRowCount != 1 GOTO ERROR1
select @intRowCount = 1
end
end
if (@OpMode = '2')
begin
select Top 1 @EngineStreamNO= EngineStreamNO from OnLineOrder_CurrentTemp where OnLine_Process =@OnLine_Process
if not exists (select 1 from dbo.OnLineOrder_CurrentTemp where OnLine_Process =@OnLine_Process)
begin
insert into dbo.OnLineOrder_CurrentTemp (EngineStreamNO, OnLine_Process, EndTime)
values (null, @OnLine_Process, getdate())
SELECT @intRowCount=@@ROWCOUNT,@intErrorCode=@@ERROR
IF @intErrorCode <> 0 OR @intRowCount != 1 GOTO ERROR1
end
else
begin
update dbo.OnLineOrder_CurrentTemp set EngineStreamNO =null , EndTime=getdate()
where OnLine_Process =@OnLine_Process
SELECT @intRowCount=@@ROWCOUNT,@intErrorCode=@@ERROR
IF @intErrorCode <> 0 OR @intRowCount != 1 GOTO ERROR1
end
end