I have to make a trigger to insert some data into a table depending on a condition in this case it is if a value is 0.
I have the following code but it just will not work
CREATE OR REPLACE TRIGGER libloan_zero
BEFORE INSERT ON evaluation
FOR EACH ROW
DECLARE
thisopinion NUMBER(1);
thisfirstname VARCHAR2 (25);
thissurname VARCHAR2 (25);
thishire_date DATE;
thislocation VARCHAR2 (25);
thistitle VARCHAR2 (25);
thiscopy_id NUMBER (10);
begin
SELECT opinion,hire_date,copy_id
INTO thisopinion,thishire_date,thiscopy_id
FROM evaluation WHERE evaluation_id = :new.evaluation_id;
dbms_output.put_line('arse');
IF thisopinion = 0 THEN
dbms_output.put_line(thisopinion);
INSERT INTO test VALUES (thiscopy_id,thisopinion,thishire_date);
dbms_output.put_line('Record Moved');
end if;
end;
Where am I going wrong? The dbms lines are me trying to debug the problem.
Question
Vortex566
I have to make a trigger to insert some data into a table depending on a condition in this case it is if a value is 0.
I have the following code but it just will not work
CREATE OR REPLACE TRIGGER libloan_zero BEFORE INSERT ON evaluation FOR EACH ROW DECLARE thisopinion NUMBER(1); thisfirstname VARCHAR2 (25); thissurname VARCHAR2 (25); thishire_date DATE; thislocation VARCHAR2 (25); thistitle VARCHAR2 (25); thiscopy_id NUMBER (10); begin SELECT opinion,hire_date,copy_id INTO thisopinion,thishire_date,thiscopy_id FROM evaluation WHERE evaluation_id = :new.evaluation_id; dbms_output.put_line('arse'); IF thisopinion = 0 THEN dbms_output.put_line(thisopinion); INSERT INTO test VALUES (thiscopy_id,thisopinion,thishire_date); dbms_output.put_line('Record Moved'); end if; end;Where am I going wrong? The dbms lines are me trying to debug the problem.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts