Alex,
There's a public attribute on cursor called 'updatecount' which you can
use to determine how many rows where affected for insert/update/delete
calls. It uses the underlying statement's getUpdateCount()
[http://java.sun.com/j2se/1.3/docs/api/java/sql/Statement.html#getUpdate
Count()]. Watch out for some drivers (such as MySQL) which behave
differently than might be expected, for example MySQL will only give the
number of rows deleted if there is a where clause, otherwise it's
undefined.
In Jython 2.2 'updatecount' will be deprecated in favor of using
'rowcount' for both select and for insert/update/delete as per the spec
[http://www.python.org/peps/pep-0249.html]
Let me know if you have any problems/comments.
thanks,
brian
> -----Original Message-----
> From: jython-users-admin@...
> [mailto:jython-users-admin@...] On Behalf
> Of Alex_Kotchnev@...
> Sent: Friday, August 02, 2002 8:01 PM
> To: jython-users@...
> Subject: [Jython-users] Verifying update with zxJDBC
> Importance: High
>
>
> I was wondering if there is a neat way to confirm that an
> update query ran successfully with zxJDBC. I mean that
> normally the dbcursor.execute() method returns None if is
> successful. So, if I am updating 0, 1 or more rows in the
> database, I don't have any way to know.
>
> E.g. if I run a select query on , I can check the number of
> rows that I get, but how about update queries ?
>
> Thanks,
>
> Alex Kotchnev
> Diversified Information Technologies
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Jython-users mailing list
> Jython-users@...
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
|