-
Notifications
You must be signed in to change notification settings - Fork 0
/
11.sql
40 lines (31 loc) · 1.33 KB
/
11.sql
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
37
38
39
40
SET SERVEROUTPUT ON;
DROP TABLE BOOK;
CREATE TABLE BOOK (
ACCNO NUMBER(4),
TITLE VARCHAR2(100),
AUTHOR VARCHAR2(20),
PUBLISHER VARCHAR2(20),
EDITION VARCHAR2(10),
NO_COPY NUMBER(10)
);
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1001, 'Moby Dick', 'Herman Melville', 'Harper & Brothers', 'First', 3);
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1002, 'War and Peace', 'Leo Tolstoy', 'The Russian Messenger', 'Second', 4);
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1003, 'Crime and Punishment', 'Fyodor Dostoevsky', 'The Russian Messenger', 'First', 6);
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1004, 'The Odyssey', 'Homer', 'Penguin Classics', 'Revised', 8);
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1005, 'The Iliad', 'Homer', 'Penguin Classics', 'Revised', 7);
CREATE OR REPLACE TRIGGER TOTAL_TUPLE
AFTER INSERT OR DELETE OR UPDATE ON BOOK
DECLARE
NO NUMBER;
BEGIN
SELECT COUNT(*) INTO NO FROM BOOK;
DBMS_OUTPUT.PUT_LINE('NO OF TUPLE: ' || NO);
END;
/
INSERT INTO BOOK (ACCNO, TITLE, AUTHOR, PUBLISHER, EDITION, NO_COPY)
VALUES (1006, 'The Hobbit', 'J.R.R. Tolkien', 'George Allen & Unwin', 'First', 5);