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
Can we write insert statement in function in oracle?
What do you understand by a database object?
how the indexes are stored in the Oracle Database?
Explain overloading. Can functions be overloaded?
How to start your 10g xe server?
What is private procedure oracle?
What are operators in oracle?
hello friends Im doing my final year engineering in B.Tech.. one of uncle said he can provide job in his company if im good in database management. but i have only basic knowledge about database, so like to join database management course in good intuition. so friends kindly help me to get good intuition because its my future.
How do you get nicely formatted results from an oracle procedure that returns a reference cursor?
How to change user password in oracle?
Explain implicit cursor.
How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?
How to delete an existing row from a table in oracle?
Explain the difference between replace() and translate() functions in oracle?
what is the difference between substr and instr function in oracle?