kevn81 / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

Exception handling within stored procedures is not supported #302

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

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()

Original issue reported on code.google.com by dmadise...@equiscript.com on 14 Dec 2012 at 4:18

GoogleCodeExporter commented 9 years ago
Running Python 2.7
Running pyodbc 3.0.2
Running Windows 7

Woops

Original comment by dmadise...@equiscript.com on 14 Dec 2012 at 4:21

GoogleCodeExporter commented 9 years ago
*3.0.6

Original comment by dmadise...@equiscript.com on 14 Dec 2012 at 4:21

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 29 Mar 2013 at 12:00