[python-sybase] Connection unusable after an exception has been raised
Josh Close
Josh Close <narshe at gmail.com>
Fri, 3 Sep 2004 14:04:50 -0500
I'd like to know this too, I've run into the same problems.
-Josh
On Fri, 3 Sep 2004 13:45:07 -0500, Skip Montanaro <skip@pobox.com> wrote:
>
> If a cursor's execute() method results in an error (say, from a trigger
> failing for some reason) it appears there is no recourse to continue other
> than closing the connection and starting over. Here's the simple test case:
>
> c = Sybase.Connection(...)
> c1 = c.cursor()
> c1.execute("select * from blah")
> c2 = c.cursor()
> c2.execute("select 1")
>
> The first execute() call results in a DatabaseError exception because there
> is no column "blah". The second execute() call also fails with a
> DatabaseError, this time in ct_send. The message is:
>
> ct_send(): user api layer: external error: This routine cannot be called
> because another command structure has results pending.
>
> How do I toss those pending results? I've tried wrapping the c1 calls in
> c.begin()/c.rollback() calls. I've tried closing and/or deleting c1. I've
> tried fetching the nonexistent results of the failed execute() call.
> Nothing seems to make Sybase happy again until a new connection is created.
>
> Is there a better (less sledgehammer-like) way to recover from errors?
>
> Thanks,
>
> --
> Skip Montanaro
> Got spam? http://www.spambayes.org/
> skip@pobox.com
> _______________________________________________
> Python-sybase mailing list
> Python-sybase@www.object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase
>