Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Triggers
Message
From
17/09/2002 12:53:36
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00701299
Message ID:
00701356
Views:
17
Nadya,

Yes, I know the deleted() does not work (see towards the bottom of my first reply). The record validation is not invoked when a record is deleted.
On the other hand, the trigger is invoked for a delete but won't let you changed the record.


options
(1) Do you need the D ? can you test for deleted() ?

The record validation fires when a deleted record is recalled.

In short, the record validation is only fired when the contents of a record have been touched or record recalled

Why do you need the D ?


(2) keep a log table somewhere. this can be done with the triggers, although I'm not in favour of that for just a flag

(3) Instead of a flag, add 2 datetime fields, One for dateCreated, and one for DateLastModified (Overkill)


(4) ???

>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
>>*-------------------------------------------------------------------------
>>
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform