General information
Title:
Tranactions and Views Problem
Dear All
RE:Problem Appended Records & Transactions with Local Views
I have come across a problem when trying to update data using a local view. I want to insert several records in the view and then use nested transactions to modify the records before committing the new records to the base table. The problem is when I make the second change in the second transaction it scrambles the changes I made in the first level and causes a record out of range error. I have simplified the code below so that you can try it for yourself. Any help or explanation would be greatly appreciated.
&&create a test table
CREATE TABLE BASETBLE (FLDA I(4) PRIMARY KEY, FLDB C(10), FLDC C(10))
&& create a view to extract data from it
CREATE SQL VIEW BASEVIEW AS SELECT * FROM BASETBLE WHERE FLDA=?lnID
&& make the view updatable
=DBSETPROP("BASEVIEW.FLDA","Field","Updatable",.T.)
=DBSETPROP("BASEVIEW","View","SendUpdates",.T.)
LOCAL lnId,lnCnt
lnId=0
&& open the view (no data comes through because the base table is empty)
USE BASEVIEW
&& set optimistic table buffering
SET MULTILOCKS ON
=CURSORSETPROP("Buffering",5)
BROWSE NOWAIT && so we can see what is going on
&& populate the view with 10 blank records
FOR lnCnt=1 TO 10
APPEND BLANK
ENDFOR
BEGIN TRANSACTION && level 1
REPLACE ALL FLDB WITH "TEST"
SUSPEND
BEGIN TRANSACTION && level 2
REPLACE ALL FLDC WITH "XYZ" && this line causes Record out of Range
&& and makes a real mess of the values
&& we have just set in FLDB
SUSPEND
&& ?TABLEUPDATE(.T.) should go in here once the rest works
END TRANSACTION && 2
END TRANSACTION && 1
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only