Answer Posted / guru
----------- without AUTONOMOUS_TRANSACTION
CREATE or REPLACE TRIGGER parts_trig
BEFORE INSERT ON parts
FOR EACH ROW
BEGIN
INSERT INTO parts_log VALUES(:new.pnum, :new.pname);
END;
/
INSERT INTO parts VALUES (1040, 'Head Gasket');
COMMIT;
INSERT INTO parts VALUES (2075, 'Oil Pan');
ROLLBACK;
SELECT * FROM parts ORDER BY pnum;
SELECT * FROM parts_log ORDER BY pnum;
----------- using AUTONOMOUS_TRANSACTION
CREATE or REPLACE TRIGGER parts_trig
BEFORE INSERT ON parts FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO parts_log VALUES(:new.pnum, :new.pname);
COMMIT; -- only for AUTONOMOUS_TRANSACTION
END;
/
INSERT INTO parts VALUES (1040, 'Head Gasket');
COMMIT;
INSERT INTO parts VALUES (2075, 'Oil Pan');
ROLLBACK;
/
Please Check This
Thanks
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Explain an index?
How to open a cursor variable?
What is an oracle and why it is used?
What is oracle used for?
Explain oracle data types with examples?
What are the common oracle dba tasks?
hi friends i completed b.com 2004.i have 3y accounting exp. in manufacturing company.now i have completed oracle finance.pls suggest me how will get job in oracle.can i get job in oracle.
Calculate difference between 2 date / times in oracle sql?
What is program global area (pga) in oracle?
What are the numeric comparison operations?
How to select some columns from a table in oracle?
How to update values on multiple rows in oracle?
Can we insert data in view oracle?
How many types of segments in Oracle?
How to put more than 1000 values into an oracle in clause?