Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Triggers
Message
 
 
À
17/09/2002 11:59:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00701299
Message ID:
00701347
Vues:
20
Hi again,

It works, but deleted() doesn't work, e.g. I can not automatically set a "D" flag.

>>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
>*-------------------------------------------------------------------------
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform