Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server Transactions Blues
Message
De
13/05/2004 18:25:31
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00903691
Message ID:
00903878
Vues:
18
This message has been marked as the solution to the initial question of the thread.
Hi Martin,

Batched update can be used as a workaround. CursorAdapter wraps entire batch into transaction, if all updates/inserts/deletes fit into one batch, they all going to be rollbacked in case of a failure. Of course, using batch update has some implications, for example, Before/After events are not raised for each record.

Here is a modification of your code that uses batched update:
Select cCustomers

* make sure all updates fit into one batch
oCA.BatchUpdateCount=RECCOUNT()

* To use batched update, all commands should use the same command object
oCA.InsertCmdDataSourceType=oCA.UpdateCmdDataSourceType
oCA.DeleteCmdDataSourceType=oCA.UpdateCmdDataSourceType
oCA.InsertCmdDataSource=oCA.UpdateCmdDataSource
oCA.DeleteCmdDataSource=oCA.UpdateCmdDataSource

If TableUpdate(.T.)
Else 
 = AERROR( laErrorArray )
 *MessageBox( Transform(laErrorArray( 1 )) + ' ' + laErrorArray( 2 ) )
 ?laErrorArray( 1 )
 ?laErrorArray( 2 ) 
EndIf 
Here is Sql Profiler Trace:
SQL:BatchCompleted set implicit_transactions on 
RPC:Completed exec sp_executesql N'UPDATE Customers SET CompanyName=@P1  WHERE CustomerID=@P2  AND CompanyName=@P3 ; 
 UPDATE Customers SET CompanyName=@P4  WHERE CustomerID=@P5  AND CompanyName=@P6 ', 
 N'@P1 nvarchar(40),@P2 nvarchar(5),@P3 nvarchar(40),@P4 nvarchar(40),@P5 nvarchar(5),@P6 nvarchar(40)', 
 N'# Que Delícia                           ', N'QUEDE', N'Que Delícia                             ', 
 N'# Queen Cozinha                         ', N'QUEEN', N'Queen Cozinha                           '
SQL:BatchCompleted IF @@TRANCOUNT > 0 COMMIT TRAN 
Thanks,
Aleksey.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform