0

is it possible for a trigger to handles two tables ?

my question,
"Write a PL/SQL trigger that, on the insertion of a donation, will set its bloodGroup to the donor's blood group if the donationType is 'whole' or 'platelets', and null if the donationType is 'plasma'."

and my trigger

create or replace trigger Tri 
before insert on DONATION
for each row
begin
if :NEW.donationType = 'plasma' then
dbms_output.put_line(:NEW.donationType || ' detected !');
:new.donationType := 'null';
dbms_output.put_line('The donationType will set to ' || :NEW.donationType);

end if;
end;
/
show errors

now im stucked, i dont have a picture for a trigger to involves two tables, any one can give some hints to me ?

and lastly why my trigger doesn't work for this action ? but it works for insertions that without involving the create the table

drop table DONATION cascade constraints;
create table DONATION (
    donationID      CHAR(7) primary key,
    donationDate    DATE,
    donorID         CHAR(4) references DONOR (donorID),
    donationType    VARCHAR(9),
    bloodGroup      VARCHAR(3),
    donationSize    INTEGER
);
insert into DONATION values ('XYZ0001','12-Mar-2008','1235','whole','O-',613);
insert into DONATION values ('ABC0998','12-Mar-2008','1236','plasma',NULL,617);
insert into DONATION values ('DEF4444','26-Mar-2008','1236','platelets','AB-',612);
insert into DONATION values ('XYZ0032','26-Mar-2008','1237','whole','O+',615);
insert into DONATION values ('DEF0900','12-Mar-2008','1238','platelets','O+',614);
insert into DONATION values ('ABC5555','26-Mar-2008','1238','plasma',NULL,613);
insert into DONATION values ('XYZ0090','26-Mar-2008','1234','whole','A+',611);
insert into DONATION values ('XYZ0095','26-Mar-2008','1239','whole','B+',613);
3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by debasisdas
0

hi..
You cannot use a DDL inside a trigger as they will manipulate or create a table for each record insert or update.. try something else..

0

hi..
You cannot use a DDL inside a trigger as they will manipulate or create a table for each record insert or update.. try something else..

errr... can you tell me what DDL is ? sorry for being unwisdom

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.