Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: May 07, 2025 - 4:17 pm UTC

Last updated: May 08, 2025 - 2:14 am UTC

Version: 19c

Viewed 100+ times

You Asked

Hi Tom,

I am trying to view explain plan for a select statement in Livesql built on 19c oracle version.
I am able to view the explan result using
select * from table(dbms_xplan.display_cursor);
but i see Error: cannot fetch last explain plan from PLAN_TABLE while using select * from table(dbms_xplan.display);
Could you please help me understand .



explain plan for select * from customers where id = 1;

select * from TABLE(DBMS_XPLAN.DISPLAY);

PLAN_TABLE_OUTPUT
Error: cannot fetch last explain plan from PLAN_TABLE

select * from customers where id = 1;

select * from table(dbms_xplan.display_cursor);

PLAN_TABLE_OUTPUT
SQL_ID 92qqjqaghv843, child number 1
-------------------------------------
SELECT O.OBJECT_NAME, O.OBJECT_TYPE, O.STATUS, E.TEXT, E.LINE,
E.POSITION FROM SYS.DBA_OBJECTS O, SYS.DBA_ERRORS E WHERE O.OBJECT_NAME

and Connor said...

I am trying to view explain plan for a select statement in Livesql built on 19c oracle version.

If you are referring to https://livesql.oracle.com/next/, then this is a limitation, because its a stateless environment.

"explain plan" put the results into a temporary table, and then dbms_xplan.display queries that temporary table.

But in a stateless environment, ie, a fresh database session between calls, the contents of the EXPLAIN PLAN are no longer present in the (fresh session) temporary table, and thus cannot be queried.

This worked in LiveSQL Classic because we ran the commands in a single session.

Using the EXPLAIN PLAN icon or hitting F10 can be used.


More to Explore

DBMS_XPLAN

More on PL/SQL routine DBMS_XPLAN here