The ORA-12841: Cannot Alter The Session Parallel DML State Within A Transaction error comes when you issue alter session enable parallel DML command when some transaction like an update, insert, delete is in progress. A transaction completes when you either issue Commit or Rollback.
As per Oracle Error Message Guide,
ORA-12841: Cannot alter the session parallel DML state within a transactionCause: Transaction in progressAction: Commit or rollback transaction and then re-execute
Let’s reproduce the ORA-12841 error,
Create a dummay table.
SQL> INSERT INTO DUMMY SELECT * FROM dual; 1 rows created
Here a row is inserted in a dummy table. Now let’s run alter command.
SQL> ALTER SESSION ENABLE PARALLEL DML; ERROR: ORA-12841: Cannot alter the session parallel DML state within a transaction
The alter command failed with the ORA-12841 error.
You have to Commit or Rollback transaction and then re-execute the alter session command to enable parallel mode in Oracle Database to resolve-12841: Cannot Alter The Session Parallel DML State Within A Transaction.
So let’s commit the session and run again the alter command. You can issue rollback command as well instead of commit.
SQL> COMMIT; Commit complete. SQL> ALTER SESSION ENABLE PARALLEL DML; Session altered.
Now alter command is successful and parallel mode is enabled.
A parallel mode can’t be set in the Oracle database unless you Commit or rollback transactions.
In essence, ORA-12841 underscores the importance of meticulous transaction and session management in Oracle database operations. Proper planning and sequencing of operations, especially concerning parallel DML, are critical to preventing such errors. It is paramount to ensure that the enabling or disabling of parallel DML operations is done outside the context of ongoing transactions.
This approach ensures seamless, efficient, and error-free database operations, optimizing the benefits of parallel processing in handling large volumes of data.
I hope you found this article helpful. Please share and subscribe.