I've just noticed a remaining problem with the pyodbc/inserts with
triggers/scope_identity()/set nocount on/nextset() thing ;-) (it's
still a workaround if I understand correctly?)
If nocount is off (eg. turned off again by the trigger as it seems in
my case), MSSQLDialect_pyodbc.do_execute jumps over the rowcount to
get to the resultset, but it is possible that there are more rowcounts
than foreseen (multiple inserts by the trigger).
I've tried the following change in MSSQLDialect_pyodbc.do_execute()
with good results:

old version, which jumps over one set in case of an exception:
            try:
                row = cursor.fetchone()
            except pyodbc.Error, e:
                # if nocount OFF fetchone throws an exception and we
have to jump over
                # the rowcount to the resultset
                cursor.nextset()
                row = cursor.fetchone()

new version, which keeps jumping as long as there are errors:
            while True:
                try:
                    row = cursor.fetchone()
                    break
                except pyodbc.Error, e:
                    # if nocount OFF fetchone throws an exception and
we have to jump over
                    # the rowcount to the resultset
                    cursor.nextset()

Probably still not ideal, but it seems better than the current one...

greetings,

Steven
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to