CREATE TABLE myStudent (
student_id NUMBER(5) NOT NULL,
department CHAR(3) NOT NULL,
course NUMBER(3) NOT NULL,
grade CHAR(1)
);
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10000, 'CS', 102, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10002, 'CS', 102, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10003, 'CS', 102, 'C');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10000, 'HIS', 101, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10001, 'HIS', 101, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10002, 'HIS', 101, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10003, 'HIS', 101, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10004, 'HIS', 101, 'C');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10005, 'HIS', 101, 'C');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10006, 'HIS', 101, 'E');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10007, 'HIS', 101, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10008, 'HIS', 101, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10009, 'HIS', 101, 'D');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10010, 'HIS', 101, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10008, 'NUT', 307, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10010, 'NUT', 307, 'A');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10009, 'MUS', 410, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10006, 'MUS', 410, 'E');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10011, 'MUS', 410, 'B');
INSERT INTO myStudent (student_id, department, course, grade)
VALUES (10000, 'MUS', 410, 'B');
CREATE OR REPLACE TRIGGER LogRSInserts
BEFORE INSERT ON myStudent
FOR EACH ROW
DECLARE
v_Status INTEGER;
BEGIN
DBMS_PIPE.PACK_MESSAGE('I');
DBMS_PIPE.PACK_MESSAGE(user);
DBMS_PIPE.PACK_MESSAGE(sysdate);
DBMS_PIPE.PACK_MESSAGE(:new.student_ID);
DBMS_PIPE.PACK_MESSAGE(:new.department);
DBMS_PIPE.PACK_MESSAGE(:new.course);
DBMS_PIPE.PACK_MESSAGE(:new.grade);
v_Status := DBMS_PIPE.SEND_MESSAGE('RSInserts');
IF v_Status != 0 THEN
RAISE_APPLICATION_ERROR(-20010, 'LogRSInserts trigger ' ||
'couldn''t send the message, status = ' || v_Status);
END IF;
END LogRSInserts;
/
show errors
drop table myStudent;
|