My question is in close connection to stackoverflow/9915788.
I am using pyodbc to upload data to an external SQL database and for this I use a stored procedure of that database. This procedure returns two things:
- a rowset (a single row which contains the text "Success" if the procedure worked fine or the text "Fail" followed by any available reason if it failed)
- an integer value (0 for success, -1 for failure)
I managed to read out the integer value using the approach described in the link above, but I would like to read out the rowset as well because I would like to get further information in case of any errors.
Any ideas how to do this? I'm not a SQL expert, but in my understanding a rowset should be a "cursor like" object since it should be possible to loop that row; but how do I get this in a select statement?
This is how I get the integer value:
def CallStoredProc(conn, procName, *args):
sql = """SET NOCOUNT ON;
DECLARE @ret int
EXEC @ret = %s %s
SELECT @ret""" % (procName, ','.join(['?'] * len(args)))
return conn.execute(sql, args).fetchall()
But I have no idea how to get the row, which should also be available somewhere..