Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Confused about Buffering and TableUpdate
Message
From
16/04/2001 19:32:38
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Confused about Buffering and TableUpdate
Miscellaneous
Thread ID:
00495972
Message ID:
00495972
Views:
45
Hi.
I am confused about how tableupdate works. I have a piece of code where I want to scan a table and based on records in this table, delete other records in other tables.

BEGIN TRANSACTION
SELECT drivertable
SCAN FOR &somecondition
primkey = drivertable.primkey
SELECT table2
DELETE FOR table2.keyfield = primkey

SELECT table3
DELETE FOR table2.keyfield = primkey
ENDSCAN

SELE drivertable
DELETE FOR &somecondition
END TRANSACTION

The question is where do I put the TABLEUPDATE. In the past I tried:
okFlag = .T.
BEGIN TRANSACTION
SELECT drivertable
IF !TABLEUPDATE()
okFlag = .F.
ENDIF

IF OKFlag
SCAN FOR &somecondition
primkey = drivertable.primkey
SELECT table2
IF !TABLEUPDATE(.T.,.T.)
okFlag = .F.
ENDIF
IF okFlag
DELETE FOR table2.keyfield = primkey
ENDIF

SELECT table3
IF !TABLEUPDATE(.T.,.T.)
okFlag = .F.
ENDIF
IF okFlag
DELETE FOR table2.keyfield = primkey
ENDIF

ENDSCAN

SELE drivertable
IF !TABLEUPDATE(.T.,.T.)
okFlag = .F.
ENDIF
IF OkFlag
DELETE FOR &somecondition
ENDIF
IF okFlag
END TRANSACTION
ELSE
ROLLBACK
=TABLEREVERT(.F.,"drivertable")
=TABLEREVERT(.F.,"table2")
=TABLEREVERT(.F.,"table3")
ENDIF


but for some reason my SCAN/ENDSCAN only processes one drivertable record and then because it did not delete the records in table2 and table3 for the second, etc. record in the drivertable file, it dies because my referential integrity rules will not allow a delete if a record exists matching its key in table2 or table3. I am setting up this routine to 'get around' the referential integrity rules when I allow purging of old data, but can't figure out what I am doing wrong. Can someone clarify how this buffering is working. I am using optimistic row buffering.

TIA
Sandi Cassidy
Next
Reply
Map
View

Click here to load this message in the networking platform