Microsoft KB Archive/140861

= FIX: Default Value Not Evaluated Properly Using Stored Procs =

Article ID: 140861

Article Last Modified on 3/24/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q140861



SYMPTOMS
Under specific circumstances where two columns are calculating default values, a stored procedure may not be executed rapidly enough resulting in default values being inserted into a table's fields instead of the data generated by the stored procedure.



CAUSE
If the stored procedure that calculates the default value takes too long, a default of 0 is used for numeric fields. This is a result of a timing issue, and not a coding issue.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 3.0b for Windows.



MORE INFORMATION
The following code, when run using Visual FoxPro 3.0, demonstrates the behavior noted in this article. After a few records, the program will fail with one of several error messages. Using Visual FoxPro 3.0b, this code runs successfully.

Steps to Reproduce Problem
  Place the following two functions into a program file called Bug.sp: FUNCTION spIncr PARAMETER cAliasName, cFname PRIVATE iNewVal lOldDel = SET ("DELETED") SET DELETED OFF SELECT MAX(&cFname) FROM (cAliasName) INTO ARRAY tmparr SET DELETED &lOldDel IF (_TALLY = 0) RETURN 1 ENDIF iNewVal = tmparr(1) + 1 RETURN iNewVal ENDFUNC

FUNCTION spDefVal PARAMETER cAliasName, cFname, aDefRetVal PRIVATE aNewVal aNewVal = .NULL. ON Error * aNewVal = aDefRetVal aNewVal = &cAliasName..&cFname ON Error RETURN aNewVal ENDFUNC   Execute the following code from a second .prg file: SET SAFETY OFF CLOSE DATABASE ALL CREATE DATABASE 'bugreport.DBC' APPEND PROCEDURES FROM 'bug.sp' COMPILE DATABASE bugreport.DBC CREATE TABLE 'bug' (NR1 I NOT NULL Default spIncr("bug","nr1"), ;                     NR2 I NOT NULL Default spDefVal("anytable", ; "anyfield",0)) ALTER TABLE 'bug' ADD PRIMARY KEY NR1 Tag NR1 INDEX ON NR2 Tag NR2

USE bug BROWSE NOWAIT FOR idat = 1 TO 200 KEYBOARD "{CTRL+Y}" && Append blank NEXT 

Additional query words: VFoxWin buglist3.00 fixlist3.00b fail

Keywords: kbbug kbfix KB140861

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.