Nianios
Nianios

Reputation: 1426

oracle EXPLAIN PLAN

I am trying to run EXPLAIN PLAN for a dynamically created sql query. Is this possible and how?

My code:

declare  
  l_sql varchar2(100);
begin
  l_sql:= 'select *from my_employees';
  EXPLAIN PLAN for l_sql; 
  commit;
end;

The error that I get is :
PLS-00103:Encountered the symbol "PLAN" when expecting on of the following: :=.(@%;

Upvotes: 2

Views: 426

Answers (1)

Nianios
Nianios

Reputation: 1426

I found the solution here

So the code should be like this:

 declare  
   l_sql varchar2(100);
 begin
   l_sql:= 'EXPLAIN PLAN for select *from my_employees';
   execute immediate l_sql;
   commit;
  end;

Upvotes: 1

Related Questions