Get explain plan for query with inline function

All we need is an easy explanation of the problem, so here it is.

I have a query that has an inline function:

with function with_f(p_text in varchar2) return varchar2 is
  begin
    return p_text;
  end;
select with_f(dummy) from dual

Is there a way to get the explain plan for that query in SQL Developer?

I tried this:

explain plan for (
with function with_f(p_text in varchar2) return varchar2 is
  begin
    return p_text;
  end;
select with_f(dummy) from dual
); 
select plan_table_output from table(dbms_xplan.display());

But I get the following error:

SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 -  "SQL command not properly ended"

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

The parentheses around the statement are wrong. It is

explain plan for stmt

and not

explain plan for (stmt);


db<>fiddle

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply