Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle

Status
Not open for further replies.

sschandhok

Programmer
Mar 13, 2002
4
0
0
US
HI ALL!

I have a problem in creating a trigger.

I have got two tables as follows:

create table temp
(
EMP_ID number(5) Primary Key,
ENAME varchar2(10)
);

create table temp2
(
EMP_ID number(5) references temp(EMP_ID),
salary number(5)
);

I am suppose to create a trigger which will not allow the user to insert any record in table temp2 if the ename in table temp is "man" suppose.

Can anyone give me solution for this.

thanking you
 
drop trigger t;

create trigger t
before insert on temp1
for each row
declare
name varchar2(20);
begin
select empname into name from temp where emp_id=:new.emp_id;

if (lower( name))='man'
then

raise_application_error(20,'sdfdfds');
end if;
end;
 

[tt]
...
raise_application_error(-20000,'sdfdfds');
^^^^^^
...
User exception codes have to be between -20000 and -20999.
[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top