ORA-01453: SET TRANSACTION must be first statement of transaction

ORA-01453: SET TRANSACTION must be first statement of transaction

Error:
Error occurred if you donot use the alter command as first line

SQL> update test set id = 1;

13010 rows updated.

SQL> ALTER SESSION SET ISOLATION_LEVEL=READ COMMITTED;
ERROR:
ORA-01453: SET TRANSACTION must be first statement of transaction

OR

SQL> set transaction isolation level serializable name 'kk';
set transaction isolation level serializable name 'kk'
*
ERROR at line 1:
ORA-01453: SET TRANSACTION must be first statement of transaction

Solution
If you want to use the same session then you have to rollback or commit the transaction before setting the isolation level
as you see in following example below:


SQL> update test set id=1;
13010 rows updated.

SQL> ALTER SESSION SET ISOLATION_LEVEL=READ COMMITTED;
ERROR:
ORA-01453: SET TRANSACTION must be first statement of transaction

SQL> rollback;
Rollback complete.

SQL> ALTER SESSION SET ISOLATION_LEVEL=READ COMMITTED;
Session altered.

Start new session then use first command in session

SQL> conn test@xepdb1
Enter password:
Connected.

SQL> SET TRANSACTION ISOLATION level SERIALIZABLE NAME 'KK1';
Transaction set.