3_6 Notes.docx - Kyle Fram 3\/6 Triggers Event-condition-action Rules Using MovieExec(name address cert netWorth Ex Make trigger to foil attempts to

3_6 Notes.docx - Kyle Fram 3/6 Triggers...

This preview shows page 1 - 2 out of 2 pages.

Kyle Fram 3/6 Triggers “Event-condition-action Rules” Using MovieExec(name, address, cert# , netWorth) Ex: Make trigger to foil attempts to lower net worth of movie executives CREATE TRIGGER NetWorthTrigger //trigger name AFTER UPDATE OF networth on MovieExec //triggering event REFERENCING OLD ROW AS OldTuple, NEW ROW AS NewTuple FOR EACH ROW WHEN ( OldTuple.networth > NewTuple.NetWorth) //condition UPDATE MovieExec SET WHERE cert# = NewTuple.cert#; Ex: Prevent average net worth of Movie Execs from dropping below $500K CREATE TRIGGER AvgNetWorthTrigger AFTER UPDATE OF networth on MovieExec REFERENCING OLD TABLE AS OldTuples, //oldtuples has previous values of tuples NEW TABLE AS NewTuples //newtuples has current value of tuples FOR EACH STATEMENT WHEN(500000>(SELECT AVG(M.networth) FROM MovieExec M)
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Fall '12
  • AlexBiliris
  • Databases, Relational model, Database trigger, 500k, Kyle Fram

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture