Home » SQL & PL/SQL » SQL & PL/SQL » Please check this ....Urgent
Please check this ....Urgent [message #40685] Wed, 30 October 2002 22:10 Go to next message
TM
Messages: 2
Registered: October 2002
Junior Member
I am Writing a Trigger as below..

Create or replace trigger checkcount after insert on emp for each row
declare
Vcount number;
erec emp%rowtype;
begin
select count(*) into VCount from emp;
if Vcount>=15 then
Select empno,ename,sal,deptno into erec.empno,erec.ename,erec.sal,erec.deptno from emp where rownum=(select min(rownum) from emp);

insert into Offlinedata.emp(empno,ename,sal,deptno) values(erec.empno,erec.ename,erec.sal,erec.deptno);

end if;
end Checkcount;

/

PLS-00201: Identifier 'EMP' must be declared
PL-SQL : sql statement Ignored.

:(( What is this ? Why is it Happening.. ?
I have checked Emp table is present in current and Offlinedata schema also.. both the users have got DBA's Privileges....

Please Help me...

TM
Re: Please check this ....Urgent [message #40687 is a reply to message #40685] Wed, 30 October 2002 22:53 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
You have many problems with this trigger. It would be helpful to know what you are trying to accomplish and then we can provide some alternatives.
Re: Please check this ....Urgent [message #40698 is a reply to message #40685] Thu, 31 October 2002 09:25 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
OK, that is pretty straightforward then. No database link is required here since we are working within the same database - just different schemas.

This is the trigger on a.emp:

create or replace trigger emp_clone
after insert on emp
for each row
begin
  insert into b.emp (empno, ename, sal, deptno)
    values(:new.empno, :new.ename, :new.sal, :new.deptno);
end;
/


B will need to 'grant insert on emp to a'.
Previous Topic: SQL VIEW
Next Topic: DATABASE TIMER
Goto Forum:
  


Current Time: Sun Apr 28 23:23:07 CDT 2024