1 / 13

Triggers Unlimited 9/24/2009 11:30am Room 6 Jeff Butera -- Hampshire College

Triggers Unlimited 9/24/2009 11:30am Room 6 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

prue
Télécharger la présentation

Triggers Unlimited 9/24/2009 11:30am Room 6 Jeff Butera -- Hampshire College

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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, realtimeprocessing • 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 Background program waits for new request Trigger requests something Background program executes request Background program stores result Background program loops

  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 '<p>' WITH '<P>' IN X.DESC SWAP '</p>' WITH '</P>' IN X.DESC SWAP '<br>' WITH '<BR/>' IN X.DESC SWAP '<BR>' WITH '<BR/>' IN X.DESC SWAP '<hr>' WITH '<HR/>' IN X.DESC SWAP '<HR>' WITH '<HR/>' IN X.DESC SWAP '</a>' WITH '</A>' 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

More Related