Article ID: 221648
Article Last Modified on 10/15/2002
APPLIES TO
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 5.0a
- Microsoft Visual FoxPro 6.0 Professional Edition
This article was previously published under Q221648
SYMPTOMS
You have a database container (DBC) that contains several tables. The DBC contains referential integrity code generated by the Referential Integrity (RI) Builder. The RI is configured to cascade deletes from a parent to a child table, and from the child table to another child table. When a record is deleted from the parent table, the stored procedure that performs the cascaded delete does not immediately reselect the correct work area after the delete occurs.
CAUSE
In the code created by the Referential Integrity Builder, the local variable lcStartArea is declared in both the insert and update code, but not in the delete code.
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This bug was corrected in Visual Studio 6.0 Service Pack 3.
For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
MORE INFORMATION
Steps to Reproduce Behavior
Run the following code from a program (.PRG) file:
#DEFINE CRLF CHR(13)+CHR(10) CLOSE DATA ALL * Make the DBC CREATE DATABASE 'RITEST.DBC' * Add the stored procedures. Because STRTOFILE() was not available in * VFP 5, you will have to create this stored procedure manually STRTOFILE("PROC RITestProc"+CRLF+ ; " messagebox([Current work area is ]+str(select()))"+CRLF +; "ENDPROC", 'procs.txt') APPEND PROC FROM 'procs.txt' OVERWRITE DELETE FILE procs.txt * Make the tables, indexes, relations, and trigger CREATE TABLE 'RITBL1.DBF' NAME 'RITBL1' (FLD1 C(10) NOT NULL ; PRIMARY KEY, FLD2 C(25) NOT NULL) CREATE TRIGGER ON 'RITBL1' FOR DELETE AS RITestProc() CREATE TABLE 'RITBL2.DBF' NAME 'RITBL2' (FLD1 C(10) NOT NULL, ; FLD2 D NOT NULL PRIMARY KEY) ALTER TABLE 'RITBL2' ADD FOREIGN KEY FLD1 TAG FLD11 ; REFERENCES RITBL1 TAG FLD1 CREATE TABLE 'RITBL3.DBF' NAME 'RITBL3' (FLD2 D NOT NULL, ; FLD3 C(25) NOT NULL) ALTER TABLE 'RITBL3' ADD FOREIGN KEY FLD2 TAG FLD2_3 ; REFERENCES RITBL2 TAG FLD2 * Add the data INSERT INTO RITBL1 VALUES('1', 'One') INSERT INTO RITBL2 VALUES('1', DATE()) INSERT INTO ritbl3 VALUES(DATE(), "Today") * Open the Database Designer to run RI builder MODIFY DATABASE * Delete the record in RITBL1 to demonstrate behavior USE RITBL1 IN 1 DELETE FROM RITBL1 WHERE FLD1=='1'
- When the Database Designer is displayed, right-click on the Database Designer, and select Edit Referential Integrity from the Context menu.
- When the Referential Integrity Builder is displayed, click the Rules for Deleting tab. Select the first record in the grid, and click the Cascade option.
- Select the second record in the grid, and click the Cascade option, then click OK. If performed properly, the Delete column for both of the grid's records contain the word "Cascade."
- Click Yes in each of the two warning dialogs that appear.
- Close the Database Designer. The messagebox appears, showing that the current work area is 2.
(c) Microsoft Corporation 1999, All Rights Reserved. Contributions by Jim Saunders, Microsoft Corporation.
Keywords: kbbug kbfix kbcodesnippet kbdatabase kbvs600sp3fix KB221648