SQL try catch处理
2024-08-27 09:37:20
ALTER PROC usp_AccountTransaction @AccountNum INT, @Amount DECIMAL AS BEGIN BEGIN TRY --Start the Try Block.. BEGIN TRANSACTION -- Start the transaction.. UPDATE MyChecking SET Amount = Amount - @Amount WHERE AccountNum = @AccountNum UPDATE MySavings SET Amount = Amount + @Amount WHERE AccountNum = @AccountNum COMMIT TRAN -- Transaction Success! END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK TRAN --RollBack in case of Error -- you can Raise ERROR with RAISEERROR() Statement including the details of the exception RAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), 1) END CATCH END GO
最新文章
- PHP之session与cookie
- ListView+CheckBox实现全选 单击效果
- mybatis入门基础(二)----原始dao的开发和mapper代理开发
- ComponentOne 2016 V3 发布
- Python QRCODE
- ZJOI2016 Round 1 之前
- linux学习笔记1
- 装过photoshop后出现configuration error
- Jquer学习
- web服务器压力测试工具
- 扩展欧几里得算法(extended Euclidean algorithm)的一个常犯错误
- CC++初学者编程教程(5) 安装codeblocks软件开发环境
- html 5 新增标签及简介
- angular 表单验证
- OOP编程七大原则
- c++ cin cin.getline() getline()用法
- 1095 Anigram单词
- Git 学习笔记--删除错误提交的commit
- 基于jQuery+CSS3实现人物跳动特效
- Extjs4.2 TreeView TreeStore 移除节点不触发delete(remove node don't trigger delete method)