Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Transaction handling via SPT
Message
De
21/03/2002 13:36:31
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Titre:
Transaction handling via SPT
Divers
Thread ID:
00635645
Message ID:
00635645
Vues:
41
I have the following block of code starting a transaction on the SQL server and then issuing a collection of batch commands. I finish by rolling back or committing the transaction. This is the first I've handled transactions in SQL. This works fine, but wondering if I'm missing anything with regards to transaction handling and if there are any obvious holes in the logic below. I stripped any error handling and am just needing advice on the transaction handling. Thanks in advance!


lnRetVal = 1
llCommitTrans = .T.
lnRetVal = SQLEXEC(lnHandle, 'BEGIN TRANSACTION SomeTransaction')
GO TOP IN csrLocalCursor
DO WHILE NOT EOF('csrLocalCursor') AND lnRetVal > 0
lcSql = "EXEC SomeStoredProcedure '" + csrLocalCursor.SomeParameter + "'"
lnRetVal = SQLEXEC(lnHandle, lcSql)
IF lnRetVal < 1
lnRetVal = SQLEXEC(lnHandle, 'ROLLBACK TRANSACTION SomeTransaction')
llCommitTrans = .F.
EXIT
ENDIF
SKIP IN csrLocalCursor
ENDDO

IF llCommitTrans
lnRetVal = SQLEXEC(lnHandle, 'COMMIT TRANSACTION SomeTransaction')
ENDIF
Répondre
Fil
Voir

Click here to load this message in the networking platform