Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Transactions
Message
 
 
To
14/04/2000 19:14:27
Larry Long
ProgRes (Programming Resources)
Georgia, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00359923
Message ID:
00365438
Views:
11
Not really...

Let's see if we can't straighten this issue out....

Larry, it is important to distinguish between transaction capabilities for VFP data as opposed to tx capabilities for remote data. Begin/End Transaction are for VFP data. When you are dealing with SQL Server data, you are dealing with an entirely different set of rules. For one thing, much of what occurs is outside the control of VFP..

Lets go through an example...

Lets say I have a Remote View called customers which points to a customers table in a SQL Server Database called foo.

Let's assume that table buffering (level 5) is involved...

If I were to issue code like this:

Begin Transaction

Replace all name with upper(name)

Rollback

This would work, or at least, appear to work.... Remember, we are in a transaction here. And because we are in a Tx, theorhetically, the records in SQL Server should be isolated. The fact is, that data is available. Why? Because SQL server has no clue that a transaction is involved. So, the key is, how do you let SQL Server know that a Tx is involved...

One way to do this is to set the Tx processing mode to manual. The first step is in getting the connection handle from the Remote View:

nHandle = cursorgetprop("connecthandle")

Once you have the connection handle, you can set the transaction processing to manual:

nSuccess = sqlsetprop(nHandle,"transactions",2)
If nSuccess = 1
*/ the command was successful...
Endif

Now, if you issue code like this:

Replace all name with upper(name)

At this point, if you try to access these records in SQL Server, you can't, since they are involved in a Tx, and more importantly, SQL Server knows about the Tx.

Now, if we wish to commit the changes, we can issue this line of code:

nSuccess = sqlcommit(nHandle)


Or, we can rollback the Tx:

nSuccess = sqlrollback(nHandle)

The bottom line, you need to have control over the process. Further, you need to let SQL Server know what is going on. While there are Tx processing capabilities in VFP, they are primarily for VFP Data. In order to have full/robust Tx processing capabilities with SQL Server, you need to communicate directly with SQL Server, and most importantly, control the process....
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform