Triggers are fired from within a transaction invoked by U2 and follow
normal transaction semantics. You *always* need to lock records (readu
or recordlocku) for write and it's best practice to use a readL (at
least) for reads.

Another thing which catches newbs out is that you will not be able to
use DEBUG in any program which runs in a transaction - including a
trigger program - as this violates the rules which include no input
during a transaction. You will need to use alternative techniques to
debug like crt statements.

Like John Israel, we also use a stub trigger handler which invokes
external subroutines to do the work. There are many good reasons for
doing it this way.

Also, we use a special file open subroutine to open and keep hold file
variables in common - arguably saving time for file opens. However,
files are always opened "absolutely" testing the full unix path. This
prevents unfortunate accidents (for example updating a Q-pointer to a
(remote) triggered file which updates something in the wrong (local)
account).

We manually keep the names of all our triggered files in a table and
have routines to create or drop the triggers if and when required.

If you have a trigger which, for example, does validation and fails, you
can force it to rollback an update by invoking the SetDiagnostics()
function.

Hope that helps,
Stuart Boydell


-----Original Message-----
Do I need to always add a READU before the WRITE, just  to establish a
lock? 

 
**********************************************************************
This email message and any files transmitted with it are confidential and 
intended solely for the use of addressed recipient(s). If you have received 
this communication in error, please reply to this e-mail to notify the sender 
of its incorrect delivery and then delete it and your reply.  It is your 
responsibility to check this email and any attachments for viruses and defects 
before opening or sending them on. Spotless collects information about you to 
provide and market our services. For information about use, disclosure and 
access, see our privacy policy at http://www.spotless.com.au 
Please consider our environment before printing this email. 
********************************************************************** 


_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to