On mssql, when I run the query, either calling it by name or calling EXEC and then the procedure name, it returns the result. The problem is that if I try to call result.fetchall(), it give this error: ProgrammingError: (ProgrammingError) Attempt to use a closed cursor. None None
I know that when I execute the query in the MSSQL environment it returns a result set, but sqlalchemy doesn't seem to get the result set. On May 8, 10:46 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote: > Daniel wrote: > > > Thanks Michael, > > > When I try that it produces this SQL > > SELECT claim_highest_priority_work() AS claim_highest_priority_work_1 > > > and this error > > 'claim_highest_priority_work' is not a recognized built-in function > > name. > > this is more of an MSSQL "how to" issue then. on most databases, running > a function and returning results looks like "SELECT function()". On > oracle, its "SELECT function() FROM DUAL". What is it on MSSQL ? > > > > > On May 8, 10:20 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote: > >> Daniel wrote: > > >> > Hello, > > >> > I've created a stored procedure in MSSQL. I'm not sure how to use it > >> > in SQLAlchemy. The stored procedure is called > >> > 'claim_highest_priority_work' and I can call it directly as follows: > > >> > result = conn.execute('claim_highest_priority_work') > > >> > I know it runs because I see the result in the database, but I'm not > >> > sure how to access the return values? They exactly match one of the > >> > tables I've defined. > > >> > What's the right way to map/execute a stored procedure and > >> > subsequently access what it returns? > > >> you probably want to select from it. an expression construct which > >> achieves this would be: > > >> select([func.claim_highest_priority_work()]) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---