Session 4718 Triggers Unlimited National Harbor 6 & 7 Tuesday 4/07/2009 3:45pm Jeff Butera -- Hampshire College Pieter Crow -- Central Wyoming College
Outline What is a trigger? What can triggers do? How do you setup triggers? Trigger examples Tips and tricks Questions
What is a trigger? Piece of executed code Triggered by certain events Unidata specifics: Code is a Unibasic subroutine or function Trigger can be invoked when a record is – Created – Modified (written) – Deleted
What can triggers do? Triggers are useful for automated processing ADDOPR, CHGOPR Virtual fields too slow? – No problem, make ‘em computed with a trigger Stored computed columns Status and/or status date fields Notify ( ?) when certain things happen
How do you setup triggers? Create subroutine with 5 arguments: EXECSTAT out (0,1,2) DICT.FLAG in (“”,“DICT”) FILENAME in (“STUDENTS”) ID in (“ ”) RECORD in/out Compile and GLOBALLY catalog CREATE.TRIGGER FILENAME SUBNAME UPDATE
Trigger examples at Hampshire Find bad HTML in course descriptions Edit A/R to NOT show dorm assignment FMLA check on complete timecard Log deletes, cleanup pointers Auto assign ID Card type (& export) Validate data entered Stored computed columns (realtime)
Jeff’s tips and tricks * cleanup some simple HTML SWAP ' ' WITH ' ' IN X.DESC SWAP '<a href' WITH '<A HREF' IN X.DESC SWAP '<a HREF' WITH '<A HREF' IN X.DESC * Strip out some bad binary multibyte chars CALL H08.IC.S.FIX.BAD.ASCII.CHARS(X.DESC )
Trigger examples at Central Wyoming
Pieter’s tips and tricks
More information Unidata documentation (a little thin): Developing Unibasic Applications Chapter 4 – Maintaining Data in Files Section on database triggers
Questions Jeff Butera Pieter Crow