简单sql事务
时 间:2018-06-08 09:49:08
作 者:萤火虫 ID:66752 城市:大理
摘 要:简单的sql事务运用
正 文:
--提交事务 commit transaction
--撤销事务 rollback transaction
--全局变量 @@ERROR
--SET @errorsum=@errorsum+@@ERROR
--每条单独的语句都是一个事务,如果成功执行,则自动提交,如果错误,则撤销 这是默认模式
create table bank
(
customerEname nvarchar(200),
currentMoney money
)
insert into bank values ('张三',1000)
insert into bank values ('李四',1)
begin transaction
declare @errorSum int
set @errorSum=0
update bank set currentMoney=currentMoney-1000
where customerEname='张三'
set @errorSum=@errorSum+@@error
update bank set currentMoney=currentMoney+1000
where customerEname='李四'
set @errorSum=@errorSum+@@error
if (@errorSum<>0)
begin
print '转账失败'
rollback transaction
end
else
begin
print '转账成功'
commit transaction
end
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)
- 仓库管理实战课程(3)-需求设计说...(03.19)
- 仓库管理实战课程(2)-软件背景和...(03.18)
- 仓库管理实战课程(1)-讲师介绍(03.16)
- 统计当月之前(不含当月)的记录数怎...(03.11)