User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 429,996 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,459 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser: Programming Forums
Views: 1263 | Replies: 4
Reply
Join Date: Feb 2008
Posts: 24
Reputation: C41R0 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
C41R0 C41R0 is offline Offline
Newbie Poster

question about trigger

  #1  
Jun 7th, 2008
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);
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 76
Reputation: anto_nee is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
anto_nee anto_nee is offline Offline
Junior Poster in Training

Re: question about trigger

  #2  
Jun 7th, 2008
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..
Reply With Quote  
Join Date: Feb 2008
Posts: 24
Reputation: C41R0 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
C41R0 C41R0 is offline Offline
Newbie Poster

Re: question about trigger

  #3  
Jun 7th, 2008
Originally Posted by anto_nee View Post
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
Reply With Quote  
Join Date: Aug 2007
Posts: 76
Reputation: anto_nee is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 4
anto_nee anto_nee is offline Offline
Junior Poster in Training

Re: question about trigger

  #4  
Jun 7th, 2008
do u really wanna solution???
go and ask ur teacher wht DDL is??
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,298
Reputation: debasisdas is on a distinguished road 
Rep Power: 4
Solved Threads: 84
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Nearly a Posting Virtuoso

Re: question about trigger

  #5  
Jun 11th, 2008
trigger can be defined only on one base table.
Share your Knowledge.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Oracle Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Oracle Forum

All times are GMT -4. The time now is 12:52 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC