Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to do transactions
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00479478
Message ID:
00480460
Views:
15
As somebody already pointed out, it is basically a matter of preference. I personally find the second approach easier to read than the first one.

Be aware that in the second approach you should have something like:
SQLEXEC(lnConnection, "IF @@TRANCOUNT > 0 COMMIT")

or

SQLEXEC(lnConnection, "IF @@TRANCOUNT > 0 ROLLBACK")
This is to protect you in case another process (e.g. a trigger) cancels or commit your transaction before you try do it.


>Hi,
>
>I am developing a VFP application using a SQL Server 7.0 backend.
>Can anyone explain me the difference between the two syntaxes bellow and the implications of using each of them? is there a "right" one?
>
>1. Transactions using VFP functions
>
>lnConnection = SQLCONNECT("MyDataSource", "sa", "")
>
>SQLSETPROP(lnConnection, "Transactions", 2)
>*-- Data manipulation here...
>SQLCOMMIT(lnConnection)
>
>
>2. Transactions using SPT directly against SQL Server
>
>lnConnection = SQLCONNECT("MyDataSource", "sa", "")
>
>SQLEXEC(lnConnection, "BEGIN TRANSACTION")
>*-- Data manipulation here...
>SQLEXEC(lnConnection, "COMMIT")
>
>
>Thank you very much!
Hector Correa
Previous
Reply
Map
View

Click here to load this message in the networking platform