My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 302: Exception handling within stored procedures is not supported
1 person starred this issue and may be notified of changes. Back to list
Status:  Investigating
Owner:  ----


 
Reported by dmadise...@equiscript.com, Dec 14, 2012

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
Running Python 2.7
Running pyodbc 3.0.2
Running Windows 7

Woops
Dec 14, 2012
#2 dmadise...@equiscript.com
*3.0.6
Mar 28, 2013
Project Member #3 mkleehammer
(No comment was entered for this change.)
Status: Investigating

Powered by Google Project Hosting