Creating a table in Oracle procedure
begin
  execute immediate 'create table t1 as select * from dba_users where username  =''BP''';
end;
/

SQL&gt; select username from t1;

USERNAME
----------
BP


Double quotes (") have a different meaning than having mutliple single quotes after each other (''). Use this:

BEGIN EXECUTE IMMEDIATE
'Create newTable as select * from oldTable where col1=''XXX'' and col2=''Y''';
END;