-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLaursen_Program11.sql
More file actions
33 lines (28 loc) · 868 Bytes
/
Laursen_Program11.sql
File metadata and controls
33 lines (28 loc) · 868 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
--desc user_triggers; select user_name from user_triggers;
CREATE TABLE BB_SALES_SUM (
product_id VARCHAR2(30);
total_sales NUMBER(8,2);
total_qty NUMBER(10);
);
Set ServerOutput On;
-- Create Trigger
CREATE OR REPLACE TRIGGER bb_salessum_trg
AFTER UPDATE OF orderplaced ON bb_basket
FOR EACH ROW
ENABLE
WHEN(NEW.orderplaced = 1)
DECLARE
lv_total_sales NUMBER(8,2);
lv_total_qty NUMBER(8,2);
BEGIN
IF UPDATING THEN
SET lv_total_sales = lv_total_sales + 1;
SET lv_total_qty = lv_total_qty + 1;
WHERE bb_basket.orderplaced = bb_basket.orderplaced + 1;
END;
/
--INSERT INTO BB_SALES_SUM VALUES(14);
--INSERT INTO BB_SALES_SUM VALUES(15);
--INSERT INTO BB_SALES_SUM VALUES(16);
--UPDATE BB_SALES_SUM SET user_name = 'Don King' WHERE user_name = 'John King';
--DELETE FROM BB_SALES_SUM WHERE user_name = 'Don King';