FIX: Using RI Builder & Long Table Names Makes Triggers Fail (142313)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
This article was previously published under Q142313 SYMPTOMS
Using the RI Builder's code along with tables that have long table names
and Private datasessions results in triggers constantly failing. The
underlying error causing the triggers to fail is Error 1 "File <file_name>
does not exist."
CAUSE
There are two causes. First the SET DATABASE command is scoped to Private
Datasessions. Thus, there is no Database current and the appropriate
database must be current for Visual FoxPro to be able to resolve long table
names. Second, the Referential Integrity (RI) Builder does not take this
previous issue into account.
WORKAROUND
Modify the RIOPEN procedure the RI Builder created. The modifications would
consist of finding the Database the table with the long table name belongs
to, using CURSORGETPROP(), SET DATABASE to this Database. Let the RIOPEN
routine open the table. Then use SET DATABASE to set the database back to
the original database if any.
Example Workaround
To work around this problem, make the following modifications to the RIOPEN
Procedure:
- Copy the entire RIOPEN procedure, and paste it below the "__RI_FOOTER"
- Add the following variables to the copied RIOPEN's LOCAL declarations:
__lcCurDBC, __tcOldTable
- Insert the following lines immediately after the copied RIOPEN's LOCAL
declarations:
&& Replace any spaces in Long Table name with "_".
&& because this is what VFP does in the DE, Aliases
&& are not allowed to contain spaces.
__tcOldTable=tcTable
tcTable=STRTRAN(ALLTRIM(tcTable)," ","_")
&& Find the DBC name the Table belongs to
__lcCurDBC=SET('DATABASE') &&Get any current DBC
__lcDBCName=CURSORGETPROP('DATABASE',tcTable) && Get Database Name
__lcDBCName=substr(__lcDBCName,rat('\',__lcDBCName)+1) &&Remove path
__lcDBCName=substr(__lcDBCName,1,rat('.',__lcDBCName)-1) &&Remove '.DBC'
SET DATABASE TO (__lcDBCName)
&& Restore original value, the USE needs the actual Long Table name
tcTable=__tcOldTable
- Insert the following line immediately after the first ENDIF of the
copied RIOPEN procedure:
&& Set back to original DBC
SET DATABASE TO &__lcCurDBC
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. This problem has been fixed in
Visual FoxPro 5.0 for Windows.
Modification Type: | Major | Last Reviewed: | 9/30/2003 |
---|
Keywords: | kbBug kbfix kbvfp500fix KB142313 |
---|
|