Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transaction handling via SPT
Message
From
21/03/2002 13:36:31
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Transaction handling via SPT
Miscellaneous
Thread ID:
00635645
Message ID:
00635645
Views:
40
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
Reply
Map
View

Click here to load this message in the networking platform