If you have the sql_id of the sql query, then you can create a baseline of that using below code.

DECLARE 
  l_plans_loaded  PLS_INTEGER; 
BEGIN 
  l_plans_loaded := DBMS_SPM.load_plans_from_cursor_cache( 
    sql_id => '&sql_id'); 
END; 
/ 

Suppose you have multiple plan hash value of the sql_id and you wish to create baseline with a particular plan hash value , then below one can be used.


DECLARE 
  l_plans_loaded  PLS_INTEGER; 
BEGIN 
  l_plans_loaded := DBMS_SPM.load_plans_from_cursor_cache( 
    sql_id => '&sql_id', plan_hash_value => '&plan_hash_value'); 
END; 
/