Q221648: FIX: RI Code Not Selecting Right Work Area After Cascaded Delete
Article: Q221648
Product(s): Microsoft FoxPro
Version(s): WINDOWS:5.0,5.0a,6.0
Operating System(s):
Keyword(s): kbDatabase kbvfp600 kbvfp600bug KbDBFDBC kbVS600sp3fix kbGrpDSFox kbDSupport kbCodeSnip
Last Modified: 02-SEP-1999
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 5.0, 5.0a, 6.0
-------------------------------------------------------------------------------
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 this to be a bug in the Microsoft products 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:
Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why
Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
MORE INFORMATION
================
Steps to Reproduce Behavior
---------------------------
1. 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'
2. When the Database Designer is displayed, right-click on the Database
Designer, and select Edit Referential Integrity from the Context menu.
3. 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.
4. 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."
5. Click Yes in each of the two warning dialogs that appear.
6. 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.
Additional query words:
======================================================================
Keywords : kbDatabase kbvfp600 kbvfp600bug KbDBFDBC kbVS600sp3fix kbGrpDSFox kbDSupport kbCodeSnippet
Technology : kbVFPsearch kbAudDeveloper kbVFP500 kbVFP600 kbVFP500a
Version : WINDOWS:5.0,5.0a,6.0
Issue type : kbbug
Solution Type : kbfix
=============================================================================
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.