Download presentation
Presentation is loading. Please wait.
Published byColleen Perkins Modified over 9 years ago
1
Triggers Unlimited 9/24/2009 11:30am Room 6 Jeff Butera -- Hampshire College Pieter Crow -- Central Wyoming College
2
Outline What is a trigger? What can triggers do? How do you setup triggers? Trigger examples Tips and tricks Questions
3
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 – Record Created/Updated (written) – Record Deleted
4
What can triggers do? Triggers are useful for automated, realtime processing ADDOPR, CHGOPR Stored computed columns Virtual fields too slow? – No problem, use SCC with a trigger Status and/or status date fields Notify (email?) when things happen
5
When not to use a trigger Never? Triggers invoked realtime Should run in 1 second or less Time-consuming processes not good Stored computed columns: – Status, time, dates, etc – OK – Recalculate student AR – Not OK
6
What about “expensive” calls? Time-consuming processes can be used Write code as you would normally Don’t place in trigger In trigger, fork background process: /usr/local/bin/my_script.sh & Background process can do work This is *nix only!
7
What about “expensive” calls? Another approach… Write program that runs 24x7 Waits for a request Trigger simply asks for calculation Trigger doesn’t perform actual work Background program does heavy lifting…
8
What about “expensive” calls? Background program executes request Trigger requests something Background program stores result Background program loops Background program waits for new request Background program waits for new request
9
How do you setup triggers? Create subroutine with 5 arguments: EXECSTAT out (0,1,2) DICT.FLAG in (“”,“DICT”) FILENAME in (“STUDENTS”) ID in (“0023450”) RECORD in/out Compile and GLOBALLY catalog CREATE.TRIGGER FILENAME SUBNAME UPDATE
10
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)
11
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 )
12
More information Unidata documentation (a little thin): Developing Unibasic Applications Chapter 4 – Maintaining Data in Files Section on database triggers
13
Questions Jeff Butera jeff@hampshire.edu http://jeff.hampshire.edu
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.