Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Triggers
Message
From
17/09/2002 11:59:54
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00701299
Message ID:
00701326
Views:
15
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>I want to automatically update a field in a table. If I add a record, I want to put 'A' in ModiType, if I change it, I want to put 'C' and if I delete it, I want to put "D". I tried to use triggers for this, but got can not update cursor message. How can I perform this update automatically?
>
>It's for VFP6.

Nadya,

here's a sample
procedure RecordValidationNadya()

	local i, FieldArray[1], n, Changed, Isnew
	
	n = afields(FieldArray)
	Changed = FALSE
	IsNew = FALSE
	
	do case
	case isnull(oldval(FieldArray[1, 1]))
		&& it's a new record
		Isnew = TRUE
	otherwise
	
		for i = 1 to n
			if( FieldChanged(FieldArray[i, 1]) )
				Changed = TRUE
				exit
			endif
		endfor
	endcase
	
	do case
	case Isnew
		&&
	case Changed
		&&
	endcase

endproc
*---------------------------------------------------------------------------
function FieldChanged(FieldName)

	do case
	case isnull(oldval(FieldName)) or Isnull(eval(FieldName))
		return (isnull(oldval(FieldName)) <> Isnull(eval(FieldName)) )
	otherwise
		return (oldval(FieldName) <> eval(FieldName))
	endcase
endfunc
*-------------------------------------------------------------------------
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform