declare v_res varchar2(4000); v_sql varchar2(4000); v_head varchar2(4000); v_last varchar2(4000); v_sqlall varchar2(4000); begin for i in (select * from user_tables a where rownum < 10) loop v_head := 'select ' || '''' || 'public static class ' || i.table_name || '{ ' || '''' || ' from dual '; v_last := 'select ' || '''' || '} ' || '''' || ' from dual '; v_sql := 'select * from (select ' || '''' || ' public static string a.COLUMN_NAME = ' || '''' || '||' || '''' || '"' || '''' || '||' || 'COLUMN_NAME' || '||' || '''' || '";' || '''' || ' ' || ' from user_tab_columns a' || ' where a.TABLE_NAME = ' || '''' || i.table_name || '''' || ' order by a.COLUMN_ID)'; v_sqlall := 'insert into test select * from (' || v_head||' union all '|| v_sql ||' union all '|| v_last||')'; execute immediate v_sqlall; --dbms_output.put_line(v_res); end loop; end;