Sql Server使用事务实现--转账问题
来源:互联网 发布:cc攻击 php网站防御 编辑:程序博客网 时间:2024/05/18 06:24
create table Bank
(
Cid char(4) primary key,
balance money
)
alter table Bank
add constraint CH_balance check (balance>=10)
insert into Bank values('0001',1000)
insert into Bank values('0002',10)
update Bank set balance=balance-1000 where Cid='0001'
update Bank set balance=balance+1000 where Cid='0002'
begin tran
begin try
declare @errorsum int=0
update Bank set balance=balance-900 where Cid='0001'
set @errorSum=@errorSum+@@error
update Bank set balance=balance+900 where Cid='0002'
set @errorSum=@errorSum+@@error
commit
print '提交!!'
end try
begin catch
rollback
print '回滚!'
(
Cid char(4) primary key,
balance money
)
alter table Bank
add constraint CH_balance check (balance>=10)
insert into Bank values('0001',1000)
insert into Bank values('0002',10)
update Bank set balance=balance-1000 where Cid='0001'
update Bank set balance=balance+1000 where Cid='0002'
begin tran
begin try
declare @errorsum int=0
update Bank set balance=balance-900 where Cid='0001'
set @errorSum=@errorSum+@@error
update Bank set balance=balance+900 where Cid='0002'
set @errorSum=@errorSum+@@error
commit
print '提交!!'
end try
begin catch
rollback
print '回滚!'
end catch
打开"隐式事务":set implicit_Transactions on
关闭“隐式事务”:set implicit_Transactions off
- Sql Server使用事务实现--转账问题
- 使用SQL SERVER存储过程实现银行转账业务
- 使用SQL SERVER存储过程实现银行转账业务
- 使用SQL SERVER存储过程实现银行转账业务
- 使用存储过程、事务、webpage实现转账。
- 使用ThreadLocal控制事务实现用户转账
- 使用事务实现银行转账操作
- SQL 事务转账
- 银行转账业务-使用事务
- 使用SQL SERVER的Link Server实现分布式事务
- [SQL Server] 使用事务发布与订阅实现数据同步
- SQL Server 事务的使用
- sql server事务的使用
- SQL Server事务简单使用
- 909422229________JDBC关于转账问题事务解决
- sqlserver 2008实现的转账事务模拟
- JDBC实现银行的转账事务
- SQL Server 事务日志的问题
- unity3d 中控制手机前后摄像头切换
- C++:20129060
- 中文乱码解决
- git,刚学,记几个用法
- 设计器打不开
- Sql Server使用事务实现--转账问题
- 配置文件
- 最长单增子序列
- Linux iptables配置以及用法
- Smarty配置文件内置变量
- smarty的有关配置文件
- Ubuntu10.04下Linux内核编译的完整步骤
- 多线程一
- 创建及删除管理员用户(3种数据库)