Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

can you write commit in triggers?

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


Please Help Members By Posting Answers For Below Questions

Are truncate and delete commands same? If so why?

1086


A table t is there.If you perform insert ,update and delete then the trigger will fire.What is the minimum no of trigger required for a table.

5440


How to create an initialization parameter file?

994


How many categories of data types?

943


How to get the Installed Oracle Version Information ?

1083


In Oracle Applications We are Using Sub Ledger Accounting. When we Transfer the Data all modules (AP,AR,CE,FA) to SLA We done Some customizations? What are They??

1799


Who developed oracle & when?

955


What is set operator oracle?

931


Explain joins in oracle?

987


What is a select query statement in oracle?

907


How to pass a cursor variable to a procedure?

1049


How to define an explicit cursor in oracle?

995


How to use an explicit cursor without open statements?

1018


what is partitioning? Types of partitioning. explain? what is the new kind of partitioning type introduced in 9i?

2230


How many data types are supported?

1034