Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running Loosely Connected & row rule recursion
Message
De
08/02/2005 02:53:11
 
 
À
07/02/2005 15:49:37
Jill Derickson
Software Specialties
Saipan, CNMI
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
00984403
Message ID:
00984646
Vues:
38
Jill,


A record validation that is fired is on the alias and the recordnumber.

You'll have to trace it imo, something else in the field/record validation or triggers is changing the alias


Suggest you use the assert below

Good luck
use TableName alias FunnyTableName
repl Field1 with 'abc'


FUNCTION NewModNumber

LPARAMETERS tcTable, tcField
&& tcTable should be TableName
&& alias (in the case above) should be FunnyTableName (caps)

assert (upper(m.tcTable) == CursorGetProp('SourceName')) message 'Not on table ' + m.tcTable     && test

LOCAL liModNumber

liModNumber = AssignModNumber( m.tcTable, m.tcField )

assert (upper(m.tcTable) == CursorGetProp('SourceName')) message 'Not on table ' + m.tcTable     && test

REPLACE (m.tcField) WITH m.liModNumber
RETURN .T.

endfunc
________________________________________________________________
>Gregory,
>
>A SET STEP ON in the newModNumber procedure indicates that on entry, the ALIAS is NOT the table being modified. Hence the passing the alias via the tctable argument.
>
>maybe your point is related to the the problem, though?
>
>I'll look into your suggesstion...thanks, J
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform