Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: need help for triggers

Re: need help for triggers

From: Matthias Gresz <GreMa_at_t-online.de>
Date: Tue, 23 Feb 1999 11:51:56 +0100
Message-ID: <36D2884C.8552E044@t-online.de>

Venkat Mundrathi schrieb:
>
> I am new to oracle(triggers). I am using personal oracle 8.0,
>
> 1)The purpose of trigger is when ever I insert a new row in the emp
> table(hope you know the description) with the same empno or ename it has to
> fire and give an error message to user that the row with empno or ename is
> already exist.

create or replace trigger tbi_emp before insert on emp for each row declare l_counter number;
begin

	   select 
	   	  count(empno)
		into
		  l_counter
		from
		  emp
		where
		  empno=:new.empno
		and
		  rowid!=:new.rowid;
		if l_counter!=0 then
		   RAISE_APPLICATION_ERROR(-20000,'Got empno yet!');
		end if; 	

end;

> 2) I created a new table U_OBJECTS( name varchar(40),type
> varchar(15),created date). I inserted the values from user_objects table.
> Now i tried to create a trigger, it should fire such that when ever a new
> row is inserted in user_objects the table U_OBJECTS has to be updated( does
> this sounds ridiculous). when i was compiling thetrigger it is give me the
> following error
>
> ORA 25001- CANNOT CREATE THIS TRIGGER TYPE ON VIEWS
user_objects is a view not a table!!

>
> can you please comment on this.
>
> thanks in advance

HTH
Matthias
--
grema_at_t-online.de

Es gibt nichts Neues mehr.
Alles, was man erfinden kann, ist schon erfunden worden. Charles H. Duell, Leiter des US Patentamtes bei seinem Rücktritt 1899 Received on Tue Feb 23 1999 - 04:51:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US