Thursday, February 8, 2018
What is Mutating Table Error in Triggers
/*****************************************************************************
WHAT IS MUTATING TABLE ERROR???????????????????????????????????????????
*****************************************************************************/
CREATE TABLE mutate_tables1 ( num NUMBER );
CREATE TABLE mutate_tables2 ( id NUMBER );
INSERT INTO mutate_tables2 VALUES (NULL);
COMMIT;
CREATE OR REPLACE TRIGGER mutate_Trigger1
AFTER INSERT ON mutate_tables2
FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
UPDATE mutate_tables1
SET num = ( SELECT MAX(id) FROM mutate_tables2 );
COMMIT;
END;
/
INSERT INTO mutate_tables2 VALUES (1);
commit;
select * from mutate_tables2;
select * from mutate_tables1;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment