Welcome! Log In Create A New Profile

Advanced

Trigger on HF Database; what use are they?

Posted by David Egan 
David Egan
Trigger on HF Database; what use are they?
June 24, 2009 10:43AM
Hi
Using MSSQL database we regularly use triggers to update totals in header records. The database effectively holds 2 buffers, one with the original record and one with the new record. I have tried to do the same in HF (client side trigger but from what I can see, a server side trigger works the same), using before & after triggers on my detail file but it doesn't work. The before trigger should decrement the total by the original detail amount and the after trigger should increment it by the new detail amount. As far as I can tell though, there is only one buffer for the file so you can't access before & after details.
Is there something I am missing or is this just not possible with HF? If this is not possible, apart from writing log files I can't see that triggers are much use.

Thanks

David
Jimbo
Re: Trigger on HF Database; what use are they?
June 24, 2009 12:24PM
Hi David, I'm using before triggers to automatically build key-strings which are later on to be used for combo-boxes to let users choose a record from the file. In some cases I build complex composite key values from several fields of the record before storing it. In general, whenever the record is HAdded() or HModify()-d then the keys are built, the trigger takes care of it automatically. There are many other uses for triggers. I'd like to see an HRead..()-Trigger to prepare certain values from the record, again automatically. I heard a 'yes' from PC Soft some years ago but there's still no trigger on Hread..(). Liefe's tough. Guenter
Al
Re: Trigger on HF Database; what use are they?
June 24, 2009 02:25PM
Hello David

Could you use the FileToMemory() command to create your own buffer record as part of your first trigger.

Regards
Al
David Egan
Re: Trigger on HF Database; what use are they?
June 26, 2009 06:55AM
Thanks Guenter, Al.
Your suggestion put me on the path of a solution Al. The problem was easily solved by creating an alias of the detail file in project initialisation and then using that in the before trigger to get the initial values.

Cheers

David
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: