Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why COMMIT resolved the issue after execute immediate?

Tags:

sql

oracle

alter

BEGIN
     EXECUTE IMMEDIATE 'ALTER SESSION SET SKIP_UNUSABLE_INDEXES = TRUE';
     EXECUTE IMMEDIATE 'ALTER SESSION DISABLE PARALLEL DML' ;
END;
/

getting following error in 1 out of 3 oracle servers. oracle : 11.2.0.4

ora 12841 cannot alter the session parallel DML state within a transaction

But the system worked fine after adding COMMIT

BEGIN
     EXECUTE IMMEDIATE 'ALTER SESSION SET SKIP_UNUSABLE_INDEXES = TRUE';
     COMMIT;
     EXECUTE IMMEDIATE 'ALTER SESSION DISABLE PARALLEL DML' ;
END;
/

Why that issue not seen after adding COMMIT?

like image 952
Bhabuk Kunwar Avatar asked Apr 05 '15 13:04

Bhabuk Kunwar


People also ask

Do I need to commit after execute immediate?

Commit is not required after every EXECUTE IMMEDIATE. Certain statements do NOT require a commit; for example, if you truncate a table with TRUNCATE.

Should we commit after delete?

DELETE requires a COMMIT, but TRUNCATE does not.


1 Answers

This issue happens if you have some statements that starts any transaction prior to the mentioned block.

In My case there was simple select from the synonym which was causing the error. Once adding commit after that transaction the block executed fine.

Even in your case if after adding COMMIT prior to following statement executes without error then it is for-sure that there is some transaction for which you are missing commits.

COMMIT;  
EXECUTE IMMEDIATE 'ALTER SESSION SET SKIP_UNUSABLE_INDEXES => TRUE'; 
EXECUTE IMMEDIATE 'ALTER SESSION DISABLE PARALLEL DML' ;

For me this link was helpful http://docs.oracle.com/cd/B28359_01/server.111/b28310/ds_admin004.htm#ADMIN12167

Thanks/Refer @DavidAldridge for more clarity

like image 72
touchchandra Avatar answered Oct 12 '22 11:10

touchchandra