FUNCTION NewModNumber LPARAMETERS tcTable, tcField LOCAL liModNumber liModNumber = AssignModNumber( tcTable, tcField ) REPLACE ( tcField ) WITH liModNumber IN ( tcTable ) RETURN .T. ** End NewModNumberI am getting the error "Illegal recursion in rule evaluation" when the REPLACE statement is executed.
*********************************** ** 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 AssignModNumberI 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.