[PDO-Users]knowing if execute_many worked on all recs

pythondbo-users-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Sat, 24 Jul 2004 14:03:47 +0100
Newsgroups gmane.comp.python.db.pdo.user
Message-ID <[email protected]>
Greetings everyone,


I'm using pdo with adodbapi to connect to a visual foxpro database.
When I use an con.execute_many with params. I would like to make sure that I'm updating all the records that fit the criteria.

The reason for this is that the database is to be accessed by more than one user. So I have a timestamp field that is checked in the update sql statement. If the timestamp doesn't match it means some other user has updated the record so the update on that record will fail.

I managed to get an answer using the following approach:
1. Know in advance how many records I want to update (not a problem in this situation - could be in others);
2. execute the sql update
3. verify how many records where updated/affected.

The way is:
####

numberToUpdate = len(listWithData)
result = con.execute_many("...", listWithData)
numberOfUpdated = result._ParamExecuteMulti__cursor.rowcount

###

I wonder if this approach is ok (once then object _ParamExecuteMulti__cursor is clearly protected)?
Also, does this approach works with other modules like kinterbasdb or is it too much of a hack?

Best regards,
mjekl

------
Clix Rapidix - Aumente até 6X a velocidade da sua Internet
Adira em http://acesso.clix.pt e comece logo a navegar




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click