I am trying to have for-loop statement inside another for-loop statement where table_name used in the inner for-loop query is result of first for-loop:
declare
l_insert_count pls_integer := 0;
begin
for row_outer in (select distinct table_name, item_type from TRANSFORMATION_MAPPING) LOOP
l_insert_count := 0;
for row in (select id from ***row_outer.table_name*** where NVL(platnost_do,sysdate)>=sysdate) LOOP
execute immediate 'insert into ITEM_MAPPING(GUID,ID) VALUES(''CENDB:''' || sys_guid() || ',' || row.id || ')';
l_insert_count := l_insert_count + 1;
IF (l_insert_count > 999) THEN
l_insert_count := 0;
commit;
END IF;
END LOOP;
end LOOP;
commit;
end;
/
Body of inner loop is much more complex. Provided code is only for purpose of showing what I want to do. row_outer.table_name is variable name of table that I want loop over to do transformations I need. In the inner loop I will need to insert few milions of rows into few different tables depending on the table from outer loop.
Thank you very much :)