I have created a procedure in a package which is doing insert/delete in the table and after successful transaction, commit is done.
like this:
create
I would suggest you to refer this article. It will clarify your queries.
AUTONOMOUS_TRANSACTION
The pragma AUTONOMOUS_TRANSACTION instructs the compiler to treat the pl/sql block following the pragma as autonomous (independent) from the calling transaction.
Should you make it Autonomous transaction solely depend upon the criteria of usage. In both the ways COMMIT has to be placed inside.
Below example will illustrate it clearly.
CREATE OR REPLACE
PROCEDURE testav
AS
PRAGMA AUTONOMOUS_TRANSACTION; --Declaring is Autonomous Transaction.
BEGIN
INSERT INTO testa VALUES
('1','2',sysdate
);
commit;
END;
DECLARE
lv_num NUMBER;
BEGIN
testav; -- Calling the Procedure
lv_num:=to_number('av'); --This will fail to parse but the procedure call will be successfull even though the calling block has failed.
END;
/