wizardofsilence
IS-IT--Management
I need to enter data into an audit table using a trigger.. I created the following audit table and trigger... trigger dsnt give the expected answer...
Q - if a customer gives a 0 evaluation, the details of the attendance must be placed in an audit table..
-- cusarrive is the table which has the evaluation attribute
CREATE TABLE audit_cus(
cusname varchar2(30),
concertname varchar2(30),
evdate DATE,
venuename varchar(50),
evaluation number(1)
)
select * from audit_cus;
CREATE OR REPLACE TRIGGER QUES2TRIG
BEFORE INSERT OR UPDATE OF cusevaluation ON cusarrive
FOR EACH ROW
DECLARE
cuse NUMBER(1);
BEGIN
select cusevaluation INTO cuse from cusarrive;
IF :OLD.cusevaluation = 0 THEN
INSERT INTO audit_cus (cusname,concertname,evdate,venuename,evaluation) (
SELECT C.CUSNAME, S.CONCERTNAME, E.EVDATE, V.VENUENAME, D.CUSEVALUATION
FROM customer C JOIN cusarrive D ON C.customerid = D.customerid
JOIN event E ON D.eventid = E.eventid
JOIN venue V ON V.venueid = E.venueid
JOIN concert S ON S.concertid = E.concertid );
END IF;
END;
/
thanks for the help in advance.
GKD...
Q - if a customer gives a 0 evaluation, the details of the attendance must be placed in an audit table..
-- cusarrive is the table which has the evaluation attribute
CREATE TABLE audit_cus(
cusname varchar2(30),
concertname varchar2(30),
evdate DATE,
venuename varchar(50),
evaluation number(1)
)
select * from audit_cus;
CREATE OR REPLACE TRIGGER QUES2TRIG
BEFORE INSERT OR UPDATE OF cusevaluation ON cusarrive
FOR EACH ROW
DECLARE
cuse NUMBER(1);
BEGIN
select cusevaluation INTO cuse from cusarrive;
IF :OLD.cusevaluation = 0 THEN
INSERT INTO audit_cus (cusname,concertname,evdate,venuename,evaluation) (
SELECT C.CUSNAME, S.CONCERTNAME, E.EVDATE, V.VENUENAME, D.CUSEVALUATION
FROM customer C JOIN cusarrive D ON C.customerid = D.customerid
JOIN event E ON D.eventid = E.eventid
JOIN venue V ON V.venueid = E.venueid
JOIN concert S ON S.concertid = E.concertid );
END IF;
END;
/
thanks for the help in advance.
GKD...