Unfortunately this is the best documentation that I have seen.  I received
it from David Scoggins via U2_Digest group who got if from Bryan Thorell.  I
have written several more routines using this as a basis that I could email
to you if you like.  The list won't accept attachments.  Let me know and I
will send them to you


     TRIGGER
* The routine called by the trigger process.

   SUBROUTINE TRIGGER(TRIGGER.NAME, TRIGGER.SCHEMA, TRIGGER.FILE,
TRIGGER.EVENT
, TRIGGER.TIME, TRIGGER.NEWID, TRIGGER.NEWREC, TRIGGER.OLDID,
TRIGGER.OLDREC, T
RIGGER.ASSOC, TRIGGER.AEVENT, TRIGGER.COUNT, TRIGGER.CHAIN, TRIGGER.CASCADE)

                 **********  WARNING    **********

*  This routine must be cataloged globally not locally.

*  This is accomplished by using the I.CATALOG verb.  This verb is present
*  in both the AAON accounts and in the ON.TEST accounts or it may be
*  created by coping the CATALOG verb from the voc of the UV account into
*  the voc of any account changing is's name to I.CATALOG.

*  Do NOT overwrite the CATALOG verb in the to acount or BAD things will
happen

* It's syntax is

*  I.CATALOG  -PGM-MODS * .TRIGGER  .TRIGGER

*  It is the * .TRIGGER that makes is globally cataloed.  A globally
*  cataloged program does not need an entry in the VOC file.

                 ***********************************

   * Generic trigger to log updates to files
   * 08/23/04 gds - created, from an example by Bryan Thorell
   * 08/14/04 ttd - received from David Scoggins via U2_Digest group
   *
   * Usage notes:
   * Triggers must be globally cataloged.
   * Use ICATALOG verb - ICATALOG SRC.BP CDB.T in the RIS account
   *
   * To activate the trigger on a file:
   * CREATE TRIGGER triggername AFTER INSERT OR UPDATE OR DELETE ON filename
*  FOR EACH ROW CALLING 'CDB.T'
   *
   * To deactivate the trigger on a file:
   * DROP TRIGGER filename triggername
   * DROP TRIGGER filename ALL - drops all triggers on filename
   *
   * Parameter list:
   * TRIGGER.NAME:    name of the trigger
   * TRIGGER.SCHEMA:  name of schema (account) trigger is called from
   * TRIGGER.FILE:    name of file trigger is called on
   * TRIGGER.EVENT:   INSERT, UPDATE or DELETE
   * TRIGGER.TIME:    BEFORE or AFTER
   * TRIGGER.NEWID:   new record ID if event is INSERT or UPDATE
   * TRIGGER.NEWREC:  new record if event is INSERT or UPDATE
   * TRIGGER.OLDID:   old record ID if event is UPDATE or DELETE
   * TRIGGER.OLDREC:  old record if event is UPDATE or DELETE
   * TRIGGER.ASSOC:   name of dynamically normalized association
   * TRIGGER.AEVENT:  event (INSERT, UPDATE or DELETE) on association
   * TRIGGER.COUNT:   number of triggers currently firing
   * TRIGGER.CHAIN:   number of active triggers since last cascade
   * TRIGGER.CASCADE: cascaded event (UPDATE or DELETE) firing the trigger
   *
   EQU DELIM TO '_'
   *

*   CRT 'EVENT ':TRIGGER.EVENT

   *
   * Create the Log Record
   R.TRANS = '' ; K.TRANS = ''
   R.TRANS<1,1> = DATE()
   R.TRANS<1,2> = TIME()
   R.TRANS<1,3> = TRIGGER.EVENT
   R.TRANS<1,4> = @LOGNAME
   R.TRANS<1,5> = @USER.NO
   R.TRANS<1,6> = @PATH

   *
   * Write the Log Record
   BEGIN CASE
      CASE TRIGGER.EVENT EQ 'UPDATE'
         K.TRANS = TRIGGER.FILE:DELIM:TRIGGER.OLDID:DELIM:R.TRANS
         K.TRANS<2> = TRIGGER.NEWREC:'~'
      CASE TRIGGER.EVENT EQ 'INSERT'
         K.TRANS = TRIGGER.FILE:DELIM:TRIGGER.OLDID:DELIM:R.TRANS
         K.TRANS<2> = TRIGGER.NEWREC:'~'
      CASE TRIGGER.EVENT EQ 'DELETE'
         K.TRANS = TRIGGER.FILE:DELIM:TRIGGER.OLDID:DELIM:R.TRANS:'~'
   END CASE

*   CRT 'READY TO WRITE ':R.TRANS
   *
   CALL *XML.PARSE(K.TRANS,ERR.REC,FLAG)
   IF FLAG THEN
      CRT 'An error was received from the  XML.PARSE routine '
      CRT ERR.REC
   END
   *
FINALLY: *
   RETURN
   END
   *


Tom Dodds
[EMAIL PROTECTED]
708-234-9608 Office
630-235-2975 Cell

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Pamela J Robbins
Sent: Tuesday, October 03, 2006 9:31 AM
To: [email protected]
Subject: [U2] Triggers

Does anyone know where I might find good documentation on triggers?  I
haven't
worked with them before and the UniVerse manuals don't have much
documentation.

-- 
Pamela J Robbins                                   University of
Pennsylvania
Sr Programmer/Analyst                           School of Veterinary
Medicine
mailto: [EMAIL PROTECTED]                 New Bolton Center
610-444-5800
610-925-6438                                   Computer help, ext HELP
(4357)
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to