Answer Posted / rami reddy
CREATE TABLE STUDENT(SNO NUMBER(4),SNAME VARCHAR2(20),COURSE VARCHAR2(20));
ANOTHER TABLE
CREATE TABLE NEW_STUDENT(SNO NUMBER(4),SNAME VARCHAR2(20));
NOW WECAN CREATE TRIGGER FOR AUTO_INSERT FROM TABLE STUDENT TO NEW_STUDENT.AT THAT WE CAN USE 'AFTER INERT' AND 'SELECT' IN THAT TRIGGER, AT THAT WE GET THIS TYPE OF ERROR
1 CREATE OR REPLACE TRIGGER ATUO_INSERT1
2 AFTER INSERT ON STUDENT
3 FOR EACH ROW
4 BEGIN
5 INSERT INTO NEW_STUDENT
6 SELECT :NEW.SNO,:NEW.SNAME FROM STUDENT;
7* END AUTO_INSERT1;
SQL> /
Trigger created.
SQL> INSERT INTO STUDENT VALUES(120,'RAJ','ORACLE');
INSERT INTO STUDENT VALUES(120,'RAJ','ORACLE')
*
ERROR at line 1:
ORA-04091: table SCOTT.STUDENT is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.ATUO_INSERT1", line 2
ORA-04088: error during execution of trigger 'SCOTT.ATUO_INSERT1'
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is Materialized View? In What Scenario we Use Materialized View?
what is a database? : Sql dba
How do you know if a relationship is 2nf?
Why truncate is used in sql?
Explain the purpose of %type and %rowtype data types with the example?
What is the difference among union, minus and intersect?
How can we implement rollback or commit statement in a trigger?
What are the sql versions?
What is difference between procedure and trigger?
Is join and inner join the same?
What are the types of sql commands?
What is the difference between delete and truncate statement in sql?
What are the types of keys?
Is nosql faster than sql?
How does cross join work in sql?