| Issue 302: | Exception handling within stored procedures is not supported | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Using a try, catch within a stored procedure elicits an error on catch.
Works perfectly fine executing from SSMS.
pulls:
Traceback (most recent call last):
File "test.py", line 7, in <module>
cursor.commit()
pyodbc.Error: ('HY000', 'The driver did not supply an error!')
---------------------------------------------
Running Python 3.0.2
Running Windows 7
---------------------------------------------
SQL SCRIPT:
----
USE Database
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [PyodbcErrorTest]
AS
BEGIN
BEGIN TRY
----
IF EXISTS(SELECT * FROM sysobjects WHERE name = 'test')
DROP TABLE test
select * from test -- Trigger error
----
END TRY
----
-- Error Handle
Begin CATCH
select * into test from worked -- where worked is a persistent table
-- test is never populated
END CATCH
END
---------------------------------------------
PYTHON SCRIPT:
import pyodbc
conn = pyodbc.connect('DRIVER={SQL Server}; SERVER=127.0.0.1; DATABASE=Database; UID=user; PWD=pass')
cursor = conn.cursor()
cursor.execute("exec PyodbcErrorTest")
cursor.commit()
print('Will not Print')
conn.close()
Dec 14, 2012
#1
dmadise...@equiscript.com
Dec 14, 2012
*3.0.6
Mar 28, 2013
(No comment was entered for this change.)
Status:
Investigating
|