Presentation is loading. Please wait.

Presentation is loading. Please wait.

Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 1 Thursday, March 12, 12:30 – 13:30PM. MIDTERM.

Similar presentations


Presentation on theme: "Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 1 Thursday, March 12, 12:30 – 13:30PM. MIDTERM."— Presentation transcript:

1 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 1 Thursday, March 12, 12:30 – 13:30PM. MIDTERM

2 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 2

3 Triggers A trigger is a statement that is executed automatically by the system as a side effect of a modification to the database. To design a trigger mechanism, we must: –Specify the conditions under which the trigger is to be executed. –Specify the actions to be taken when the trigger executes. Introduced to SQL standard in SQL:1999, Supported even earlier using non-standard syntax by most DBMSes. –Syntax illustrated here is for Oracle 11g.

4 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 4

5 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 5

6 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 6

7 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 7

8 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 8

9 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 9

10 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 10

11 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 11

12 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 12

13 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 13 Triggers are commonly used to monitor events occurring in a database. AFTER Triggers

14 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 14

15 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 15

16 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 16

17 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 17 Triggers for Views Recall updateable views?

18 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 18

19 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 19

20 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 20

21 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 21 Triggers on DDL Statements What’s a DDL statement?

22 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 22

23 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 23

24 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 24 Disable/Enable Triggers Why would I want to disable a trigger?

25 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 25

26 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 26

27 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 27 Compound Triggers Why do we need another type of trigger? It solves an well-known problem in Oracle. Contains code that executes: BEFORE the triggering statement executes. BEFORE the row is modified. AFTER the row is modified. AFTER the triggering statement has finished.

28 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 28

29 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 29

30 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 30

31 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 31

32 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 32

33 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 33

34 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 34

35 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 35

36 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 36

37 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 37

38 Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 38


Download ppt "Murach’s Oracle SQL and PL/SQL, C16© 2014, Mike Murach & Associates, Inc.Slide 1 Thursday, March 12, 12:30 – 13:30PM. MIDTERM."

Similar presentations


Ads by Google