Illegal recursion in rule evaluation error in trigger

Microsoft Visual FoxPro - Programmer Exchange

sm
Hi All,

I have an update trigger written on a table. The stored procedure for the trigger is as follows:

PROCEDURE updTicketTrigger
DIMENSION tcount(1) as Integer
	select count(*) from <tablename>  where <condition> into ARRAY tcount noconsole
	IF (tcount[1]) = 1
		tcount[1] = 0
		FOR i = 1 TO 500
			DO WHILE .t.
                                                    &&setting value1 and value2 for field1,field2
		                ENDDO 

			INSERT INTO tablename(field1, field2) values(value1, value2)
		ENDFOR
	
	ENDIF 
RETURN .t.
ENDPROC 

On execution of the trigger, the following error message is displayed on the very first insert itself!
Illegal recursion in rule evaluation.

Can't we use loops in triggers?

Any help is greatly appreciated.
Regards.
                                            
Stefan
Sounds as if the target "tablename" is the same as the trigger's
owner table, right? If so, in Vfp you cannot self-update a table in
its own update trigger, literally because of the resulting recursion.

Alternatively, you could use the table's "Record validation rule"
(although I think maybe you don't want to, as it seems you're
storing some calculated values depending on other columns,
which breaks "normalization" rules and actually almost always
makes app design / code maintenance much more complicated)


hth
-Stefan

is as follows:
field1,field2
first insert itself!