奇怪的现象:调用存储过程中无法更新表,但是直接执行SQL语句确可以更新。请各位指教!
存储过程:
CREATE PROCEDURE p_q_cash_comeback
@casher varchar(10),
@cause varchar(100),
@owner int
AS
--set nocount on
--begin transaction
declare @cashtime datetime,
@packetnum int
begin
select top 1 @cashtime=cashtime ,@packetnum=packetnum from t_q_cashinfo where userid=@owner order by cashtime desc
update t_q_cswin
set stats=1,cashtime=NULL
where cashtime=@cashtime and owner=@owner
update t_q_userinfo
set packnum=packnum+@packetnum
where userid=@owner
delete from t_q_cashinfo where cashtime=@cashtime and userid=@owner
insert into t_q_cash_bak(cashtime,owner,comebacktime,casher,cause) values(@cashtime,@owner,getdate(),@casher,@cause)
end
--endpos:
--commit transaction
--errorpos:
--rollback transaction
--eturn
GO
我在查询分析器里如下执行存储过程:
exec p_q_cash_comeback 'ligang','ligang',1011
结果无法更新t_q_cswin表,但是其他的成功执行了。
我又在查询分析器里执行如下的语句:
update qcs..t_q_cswin
set stats=1,cashtime=NULL
where owner=1011
确能成功的修改,请问这是为什么?(cashtime字段允许空)