Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange behaviour of TABLEREVERT(.T.) ?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00055291
Message ID:
00055468
Views:
28
>>>Dezider, are the two tables related in the DBC? If so, check out your RI code. It sounds like you have set your Delete code to 'Cascade'. Reverting the parent (deleting the new record from the buffer) would then automatically delete any child records.
>>>
>>>HTH
>>>Barbara
>>
>>Well, I guess I wasn't clear about this. I wrote this in a hurry so let me make it clear. So I have two tables. Pay_orders and Accounting. They are related 1:1 through field Pay_orders.ID. I set buffering to 3 for both of them in DE of form. Manually apend record to each of them. And when I choose to Cancel all changes, it does this: Checks if there are any changes,
>>Asks if I'm sure about that. And discard the buffer.
>>When I traced it I have this environment - alias() returns "Pey_orders", getfldstate(-1) returns "1111111121111", and getfldstate(-1, "Accounting") returns "333333333333".
>>And when user confirms deleting it comes =TABLEREVERT (.T.). And then it is really interesting. Debug windows changes to this alias() returns "Pey_orders", getfldstate(-1) returns .NULL., and getfldstate(-1, "Accounting") returns .NULL. TOO!. And after this when I manually select getfldstate returns "111111111".
>>The great mystery is, that the record is physically SAVED to the table even I want it to be removed! And I don't have any RI there.
>>Problem is, that it DOESN'T physically remove record in second table. And I don't understand why it does this.
>>Is it clearer now?
>
>Thanks, Dezider it's much clearer. Your problem is that you are deleting the parent record first.
>
>GetFldState(-1) will return .NULL. when a table is at eof(). When you deleted the appended record in the Pay_Orders, that table is at eof(). The Accounting table is ALSO at eof(), because of the relationship. When you issue a SELECT command to Accounting you are NOT at the correct, just-added record.
>
>Try to either remove the relationship before calling your TableRevert or doing a SEEK on your Pay_Orders ID in each table before the tablerevert() is called.
>
>HTH
>Barbara

Yes, you are absolutely right. I found this and decided not to count on RI and set RI to III, and I'm taking control of appending and removing records, including work with bufferd records. Now I'm really glad that my project doesn't require table buffering... :-) It's easier to take care of one record then multiple.
Thanx very much for help
Dezider
There were three worst disasters in the history of human
race in 20-th century:
1, Hiroshima 44
2, Tchernobyl 86
3, Windows 95
Previous
Reply
Map
View

Click here to load this message in the networking platform