那位大侠帮我看看这个存储过程有啥问题没
本人不太懂存储过程,请大侠帮忙看看这个存储过程有啥问题没,现在有个问题就是执行该存储过程程序报错“未将对象引用设置到对象的实例”存储过程如下,看看该如何修改,麻烦指点
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER procedure [dbo].[Proc_UpdateCurrentOption]
@EngineStreamNO nvarchar(50),
@OnLine_Process nvarchar(20),
@OpMode nvarchar(20)
as
declare
@intErrorCode INT,
@intRowCount INT
BEGIN TRANSACTION
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
COMMIT TRANSACTION
RETURN @intRowCount
ERROR1:
ROLLBACK TRANSACTION
RETURN -1