-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTriggers.sql
More file actions
36 lines (29 loc) · 701 Bytes
/
Triggers.sql
File metadata and controls
36 lines (29 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE TABLE superheroes (
sh_name VARCHAR2 (20)
);
--EXAMPLE 01
SET SERVEROUTPUT ON;
CREATE OR REPLACE TRIGGER bi_superheroes
BEFORE INSERT ON superheroes
FOR EACH ROW
ENABLE
DECLARE
v_user VARCHAR2 (20):= 'Carrot';
BEGIN
--SELECT user INTO v_user FROM dual;
DBMS_OUTPUT.PUT_LINE('You just inserted A Line Mr. ' ||v_user);
END;
/
SET SERVEROUTPUT ON;
CREATE OR REPLACE TRIGGER bu_superheroes
BEFORE UPDATE ON superheroes
FOR EACH ROW
ENABLE
DECLARE
v_user VARCHAR2 (20):= 'Carrot';
BEGIN
--SELECT user INTO v_user FROM dual;
DBMS_OUTPUT.PUT_LINE('You just updated A Line Mr. ' ||v_user);
END;
/
UPDATE superheroes SET sh_name = 'Superman' WHERE sh_name = 'Ironman';