Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wrapping all SQL updates into one transaction
Message
De
10/01/2000 17:40:33
 
 
À
10/01/2000 17:25:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00315804
Message ID:
00315815
Vues:
19
Carie,

My first recommendation is to call a stored procedure and let the stored procedure make all the changes. In the long run you'll get much better performance - especially if the group of updates are frequently executed.

With that said.
LOCAL hConn, lnResult
llError = .F.
hConn = SQLCONNECT(...)

*-- start a manual transaction
SQLSETPROP(hConn, "Transactions", 2)

lnResult = SQLEXEC(hConn, "UPDATE table1 ...")
lnResult = SQLEXEC(hConn, "UPDATE table2 ...")
lnResult = SQLEXEC(hConn, "UPDATE table3 ...")
lnResult = SQLEXEC(hConn, "UPDATE table4 ...")

IF (everything_is_ok)
  SQLCOMMIT(hConn)
ELSE
  SQLROLLBACK(hConn)
ENDIF

*-- You really only need to reset the transaction property if
*-- you're not going to disconnect.
SQLSETPROP(hConn, "Transactions", 1)

SQLDISCONNECT(hConn)
-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform