T-SQL Nested procedure & transactions
来源:互联网 发布:mysql free result 编辑:程序博客网 时间:2024/05/16 01:49
IF OBJECT_ID('sp_ThrowExp') IS NOT NULL
DROP PROC sp_ThrowExp
GO
CREATE PROC sp_ThrowExp
AS
RAISERROR('Error occurs.', 16, 1)
GO
IF OBJECT_ID('sp_OuterProc') IS NOT NULL
DROP PROC sp_OuterProc
GO
CREATE PROC sp_OuterProc
AS
BEGIN TRAN
BEGIN TRY
--db operations
INSERT Customer SELECT 3, 'exxx', 7
PRINT 'Before throw'
EXEC sp_ThrowExp
PRINT 'After throw'
END TRY
BEGIN CATCH
PRINT 'Catch exp'
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRAN
PRINT 'Roll back tran'
RETURN
END
END CATCH
PRINT 'Outside try/catch'
IF @@TRANCOUNT > 0
BEGIN
COMMIT TRAN
PRINT 'Commit tran'
END
GO
EXEC sp_OuterProc
/* OUTPUT
(1 row(s) affected)
Before throw
Catch exp
Roll back tran
*/
DROP PROC sp_ThrowExp
GO
CREATE PROC sp_ThrowExp
AS
RAISERROR('Error occurs.', 16, 1)
GO
IF OBJECT_ID('sp_OuterProc') IS NOT NULL
DROP PROC sp_OuterProc
GO
CREATE PROC sp_OuterProc
AS
BEGIN TRAN
BEGIN TRY
--db operations
INSERT Customer SELECT 3, 'exxx', 7
PRINT 'Before throw'
EXEC sp_ThrowExp
PRINT 'After throw'
END TRY
BEGIN CATCH
PRINT 'Catch exp'
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRAN
PRINT 'Roll back tran'
RETURN
END
END CATCH
PRINT 'Outside try/catch'
IF @@TRANCOUNT > 0
BEGIN
COMMIT TRAN
PRINT 'Commit tran'
END
GO
EXEC sp_OuterProc
/* OUTPUT
(1 row(s) affected)
Before throw
Catch exp
Roll back tran
*/
- T-SQL Nested procedure & transactions
- hibernate4在执行sql时出现nested transactions not supported
- nested transactions not supported
- nested transactions not supported
- T-SQL 中 CREATE PROCEDURE 语法
- A SQL Server DBA myth a day: (26/30) nested transactions are real
- sql server 2005 T-SQL ALTER PROCEDURE (Transact-SQL)
- 报错:nested transactions not supported
- org.hibernate.TransactionException: nested transactions not supported
- c# Nested transactions are not supported
- hibernate exception nested transactions not supported 解决方法
- 关于nested transactions not supported的问题
- SQL Azure Transactions
- Sql Sever Transactions详解
- Receiving Transactions SQL
- procedure,package,ref cursor , nested table,record ....
- Microsoft SQL Server 2005 Stored Procedure Programming in T-SQL & .NET
- org.hibernate.TransactionException: nested transactions not supported错误的解决方案
- EVC编程点滴-WM_TIMER冲突处理与精度
- 基于Ajax的编码、拼音缩写、名称模糊查询输入控件
- 用Visual C#获取系统信息四法
- Request.ServerVariables参考
- 如何以Collection变量作为数据源来向数据表中插入数据,或者更新数据。
- T-SQL Nested procedure & transactions
- java通过数组描述二叉树
- 用Java编写线程池(一)
- java通过数组描述堆栈
- 无线路由也超频 刷机从TOMATO固件开始
- SharpDevelop源码分析 (二、头绪)
- .NET 2.0 - WinForm Control - DataGridView 编程
- java通过数组描述队列和循环队列
- 酷酷的题