Skip to Main Content
  • Questions
  • setting isolation level after gather stats worked; but did not work before it. Why ?

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Akash.

Asked: April 12, 2019 - 9:56 am UTC

Last updated: April 15, 2019 - 4:57 am UTC

Version: 11

Viewed 1000+ times

You Asked

Hi,

Please see below :-

SQL> create table t (x int);

Table created.

SQL> insert into t values (1);

1 row created.

SQL> alter session set isolation_level=serializable;
ERROR:
ORA-01453: SET TRANSACTION must be first statement of transaction


SQL> exec dbms_stats.gather_table_stats( user, 'T' );

PL/SQL procedure successfully completed.

SQL> alter session set isolation_level=serializable;

Session altered.


Why did the alter session statement throw error before gathering stats and not after it ?

and Connor said...

It's nothing to do with gather stats directly - it is because you cannot the the isolation level if you have a currently active transaction. eg

SQL> create table t (x int);

Table created.

SQL> insert into t values (1);

1 row created.

SQL> commit;

Commit complete.

SQL> alter session set isolation_level=serializable;

Session altered.


The gather_stats call did a commit, which is why the alter session worked after that.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Akash Jain, April 15, 2019 - 5:42 am UTC


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library