日期:2014-05-17 浏览次数:20405 次
alter proc us
@type varchar(10),
@mon money
as
begin
begin transaction
declare @id varchar(30)
select @id=cardid from cardinfo
insert into transinfo values(getdate(),@id,@type,@mon,'wu'))
commit transaction
print '123'
end
go
alter trigger trans
on transinfo
for insert
as
begin
declare @type varchar(10),@cardid varchar(20),@mon money
select @type=transtype,@cardid=cardID,@mon=transMoney from inserted
if(@type='1')
begin
update cardinfo set balance=balance-5 where cardID=@cardid
update cardinfo set balance=balance-@mon where cardID=@cardid
end
else
update cardinfo set balance=balance+@mon where cardID=@cardid
end
declare @id varchar(30)
select @id=cardid from cardinfo
insert into transinfo values(getdate(),@id,'1',20,'wu')
print '123'