title: Oracle Baseline not being used
body: <p>I have a SQL_ID (1234567890abc) and I'm trying to bind the execution of the query to a baseline. So I'm doing the following:</p>
  
  <pre class="lang-sql prettyprint-override"><code>var v_num number;
  exec :v_num:=dbms_spm.load_plans_from_cursor_cache(sql_id =&gt;'1234567890abc',plan_hash_value =&gt; 1122334455);
  </code></pre>
  
  <p>(let's suppose 1122334455 is the plan hash for the sql_id "1234567890abc." I think it's not mandatory to set this value, but I do it anyway)</p>
  
  <p>So the baseline is added. I check it using</p>
  
  <pre class="lang-sql prettyprint-override"><code>select * from dba_sql_plan_baselines;
  </code></pre>
  
  <p>But if I execute the query two or three times again, the execution plan does not show in the notes that the baseline is now in use, and the column sql_plan_baseline for the row with sql_id = '1234567890abc' in the table v$sqlarea is null. The number of executions is incremented.</p>
  
  <p>I tried to purge the sql_id from the shared pool using:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select address, hash_value from v$sqlarea where sql_id='1234567890abc';
  execute sys.dbms_shared_pool.purge('0000000000ABCDEF,0987654321','Z');
  </code></pre>
  
  <p>But if I send the query again, a new row is created in v$sqlarea and once again the column sql_plan_baseline of the table v$sqlarea is null.</p>
  
  <p>I tried to gather all schema stats (using no_invalidate => false), and even restarting the database but nothing changes. I also tried to mark the baseline as fixed, but it was useless.</p>
  
  <p>the Oracle version is 11.2.0.1.0, the parameter optimizer_capture_sql_plan_baselines is set to false and optimizer_use_sql_plan_baselines is set to true</p>
  
  <p>What am I doing wrong? Thanks in advance.</p>