Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running Loosely Connected & row rule recursion
Message
From
07/02/2005 09:22:45
 
 
To
07/02/2005 07:25:46
Jill Derickson
Software Specialties
Saipan, CNMI
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00984403
Message ID:
00984422
Views:
24
Jill,

In the RecordValidation rule, you are on the table that is being modified.
I suspect the Replace in tcTable is causing the trouble.
tcTable does not necessarily equal the alias()

Hence, try
FUNCTION NewModNumber

LPARAMETERS tcTable, tcField

LOCAL liModNumber
>
liModNumber = AssignModNumber( m.tcTable, m.tcField )
REPLACE (m.tcField) WITH m.liModNumber
RETURN .T.

endfunc
Does the error still persist ?

I do not think that modifying a record in the RecordValidation rule causes it to fire again

In the test below, you'll see that the RecordValidation is called twice, once for the insert and once for the replace
*---------------------------------------------------------------------------
function do_it()
	
	create cursor ppp (ppp I)
	=afields(aa)
	use
	aa[1,10] = 'ValidateMyRecord()'
	
	create cursor ppp from array aa
	select 999  && get off the alias
	
	insert into ppp values (2)
	repl ppp with 500 in ppp
endfunc
*---------------------------------------------------------------------------
function ValidateMyRecord()

	acti screen
	?'Called'
	
	repl ppp with 1000
	repl ppp with 1100
	repl ppp with 1200
	
endfunc
*---------------------------------------------------------------------------
>Hi,
>
>I've taken some ideas from a July 2001 FoxPro Advisor article, "Running Loosely Connected, Part 3" to synchronize updates in tables between headquarters and remote locations.
>
>A "ModNumber" field in maintained in each table. Every time any change is made to the table, the modNumber is incremented. Then when it's time to sychronize, it can be determined which records have to be updated.
>
>My problem is in the maintenance of the modNumber field.
>
>In each table, i have the record validation rule as:
>newModNumber(cThisTablename,cThisModNumberField)
>
>newModNumber is a stored procedure, as follows:
>
>
FUNCTION NewModNumber
>
>LPARAMETERS tcTable, tcField
>
>LOCAL liModNumber
>
>liModNumber = AssignModNumber( tcTable, tcField )
>REPLACE ( tcField ) WITH liModNumber IN ( tcTable )
>
>RETURN .T.
>** End NewModNumber
>
>I am getting the error "Illegal recursion in rule evaluation" when the REPLACE statement is executed.
>
>The AssignModNumber Function is:
>
>
***********************************
>** from Craig Berntson's Knowledgebase - 8/24/99
>** used to generate ModNumbers
>FUNCTION AssignModNumber
>
>LPARAMETERS tcTable, tcField
>
>LOCAL lnArea, liModNumber
>
>* Save current work area
>lnArea = SELECT()
>
>IF !USED("GeneratePK")
>  USE sagenpk IN 0 SHARED ALIAS GeneratePK
>ENDIF
>SELECT GeneratePK
>SET ORDER TO TAG GPK_PK
>
>* FLOCK seems to work a bit better than RLOCK.
>* I've never had a problem with it
>DO WHILE !FLOCK()
>ENDDO
>
>SEEK UPPER(tcTable)
>IF FOUND()
>  REPLACE gpk_CurrentModNumber WITH gpk_CurrentModNumber + 1
>  liModNumber = gpk_CurrentModNumber
>ELSE
>  INSERT INTO GeneratePK ( GPK_PK, gpk_CurrentNumber, gpk_CurrentModNumber ) ;
>    VALUES ( UPPER( tcTable ), 0, 1 )
>  liModNumber = 1
>ENDIF
>
>FLUSH
>UNLOCK
>
>SELECT (lnArea)
>RETURN liModNumber
>** End AssignModNumber
>
>
>I am using views. The VIEW doesn't have a row rule, but I THINK what might be happening is that the rule is somehow being called twice (yes, recursion....) perhaps once for the table and once for the rule? When i update the table directly, in a browse, the modNumber is incremented properly.
>
>Once i get the "Illegal recursion in rule evaluation" my only options are CANCEL and HELP. I choose CANCEL, and a PROCEDURE CANCELLED message appears. I click on OK and i'm back in the NewModNumber procedure again...on the line before the REPLACE.
>
>Any insight or help is appreciated! TIA, j
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform