很简单的一个存储过程,但运行就出问题,在查询分析器下测试没问题,但当用VC ADO调用时就出问题,pSet->IsEof()为真,既没有记录返回。
具体如下:CREATE PROCEDURE p_sz_foundFaction
@userid int,
@factionname varchar(20)
AS
set nocount on
begin transaction
declare @id int
set @id = -1select id from t_faction where FactionName = @factionname
if @@rowcount <= 0
begin
insert into t_faction (FactionName, userid) values (@factionname, @userid)
--select @id = id from t_faction where userid = @userid
当执行到这时出错,下面这句不会执行,并且放到到insert前也不执行
update t_user set faction = 1 where userid = @userid
select 0
goto endpos
endselect 1
goto endposerrorpos:
rollback transaction
return
endpos:
commit transaction
return
GO
具体如下:CREATE PROCEDURE p_sz_foundFaction
@userid int,
@factionname varchar(20)
AS
set nocount on
begin transaction
declare @id int
set @id = -1select id from t_faction where FactionName = @factionname
if @@rowcount <= 0
begin
insert into t_faction (FactionName, userid) values (@factionname, @userid)
--select @id = id from t_faction where userid = @userid
当执行到这时出错,下面这句不会执行,并且放到到insert前也不执行
update t_user set faction = 1 where userid = @userid
select 0
goto endpos
endselect 1
goto endposerrorpos:
rollback transaction
return
endpos:
commit transaction
return
GO
select @id = [id] from t_faction where userid = @userid