Using Triggers to Automate Internal Processing in Unidata - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Using Triggers to Automate Internal Processing in Unidata

Description:

FILE ( STUDENTS') ID ( 0023450') RECORD. Compile and GLOBALLY catalog ... Set billed flag for parking stickers. Detect data irregularities with evaluations ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 11
Provided by: fdciHam
Category:

less

Transcript and Presenter's Notes

Title: Using Triggers to Automate Internal Processing in Unidata


1
Using Triggers to Automate Internal Processing in
Unidata
  • Jeff Butera - Hampshire College
  • http//jeff.hampshire.edu

2
Outline
  • What is a trigger?
  • What can triggers do?
  • How do I setup a trigger?
  • How do I use them in production?
  • Questions?

3
What is a trigger?
  • Piece of executed code
  • Triggered by certain events
  • Unidata Specifics
  • Code is a Unibasic subroutine or function
  • Triggers can be invoked whenever a record is
  • Updated (written)
  • Deleted

4
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 (email?) when certain things happen...

5
How do I setup a trigger?
  • Create subroutine with 5 arguments
  • EXECSTAT (0,1,2)
  • DICT.FLAG (, DICT)
  • FILE (STUDENTS)
  • ID (0023450)
  • RECORD
  • Compile and GLOBALLY catalog
  • CREATE.TRIGGER FILENAME SUBNAME UPDATE

6
How do I use these for real?
  • Hampshire has truckloads of custom code/files
  • On ALL custom files, I use triggers for
  • ADD/CHG OPER, DATE, TIME
  • Why not Envision?
  • We use triggers on some Datatel files too!
  • We use WORKORDERS for Phys Plant and IT
  • PPWP (Web Params) only allows single Plant Type
  • and single email address for web work orders
  • No problem worked around with a trigger

7
  • SUBROUTINE H08.UT.H08.CR.EVENTS(X.EXEC,X.DICT,X.FI
    LE,X.ID,X.REC)
  • X.EXEC2
  • IF X.DICT THEN
  • X.REClt4gtUPCASE(_at_LOGNAME)
  • X.REClt5gtDATE()
  • X.REClt6gtTIME()
  • IF X.REClt1gt THEN
  • X.REClt1gtX.REClt4gt
  • X.REClt2gtX.REClt5gt
  • X.REClt3gtX.REClt6gt
  • END
  • END
  • RETURN
  • BASIC CUSTOM.SOURCE H08.UT.H08.CR.EVENTS
  • CATALOG CUSTOM.SOURCE H08.UT.H08.CR.EVENTS FORCE
  • CREATE.TRIGGER H08.CR.EVENTS H08.UT.H08.CR.EVENTS
    UPDATE

8
Non-trivial examples
  • Search for HTML tags in free-form text
  • Strip bad (unprintable) ASCII from free-form text
  • Correct WORKORDER plant/email
  • Set billed flag for parking stickers
  • Detect data irregularities with evaluations (text
    types)
  • FMLA check for approved timecards
  • Why not place this code in screens/batch
    processes?

9
Where do I find more information?
  • Unidata Documentation (thin)
  • Developing Unibasic Applications
  • Chapter 4 Maintaining Data in Files
  • Database triggers pp. 4-6

10
Questions?
Jeff Butera Hampshire College jbutera_at_hampshire.ed
u http//jeff.hampshire.edu
Write a Comment
User Comments (0)
About PowerShow.com