|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi all,
i am a newbie of oracle. i am now doing a assignment and i cant find the way the slove the problem. the problem is taht: i am required to create a trigger fired by an update statement. it will decide the tuple can be updated or not based on another table. but i cant find way to get the detail of the updated tuple. the following is some part of my assigment: create table movie ( mname VARCHAR2(50) primary key, year number(4) not null, did char(1) references director(did), d_pay number(10,2) constraint check_d_pay check(d_pay<1000000) ); create table sequel ( original_name VARCHAR2(50) PRIMARY KEY references movie(mname), sequel_name VARCHAR2(50) NOT NULL ); when update the d_pay, such as: update movie set d_pay = 5000 where mname = 'troy'; the trigger are required to check if the movie has sequel or not. if it has sequel, d_pay are not allow to be updated. can anyone teach me how to reach that purpose?? thx |
|
#2
|
|||
|
|||
|
Code:
create or replace trigger before UPDATE of D_PAY on MOVIE
for each row
declare
SN varchar2(20);
begin
select sequel_name into SN from sequel where original_name = :NEW.mname;
if SN = '' THEN
raise error NO_SEQUEL
End if
Exception
NO_SEQUEL
dbms_output.putline("NO SEQUEL")
end;
needs some improvement but this ought to do it? |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > [help]oracle trigger problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|