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
Is there any way to find out when one specific table/view/M-view is used last time. i.e. when one specific object is used in any SELECT statement.
What is a dynamic performance view in oracle?
how to make an oracle object
How to define an anonymous procedure with variables?
How to define a data source name (dsn) in odbc manager?
Using the relations and the rules set out in the notes under each relation, write table create statements for the relations EMPLOYEE, FIRE and DESPATCH. You should aim to provide each constraint with a formal name, for example table_column_pk.
How can we create the complete backup of data in the oracle.
Explain the use of parfile option in exp command.
Define oracle database
List the various oracle database objects?
What are the attributes that are found in a cursor?
Which is better Oracle or MS SQL? Why?
How to end the current transaction in oracle?
what is port in oracle? how is it related to database application.
What are ddl statements in oracle?