Answer the question
In order to leave comments, you need to log in
How to update data from one table to another table through a loop using dynamic sql?
All hello guys!
Can you help in solving the problem (It is necessary to update the data in the table tablenew table from the general_table table)
declare
tablename varchar(255) := 'CoolTable';
tablenew varchar(255);
BEGIN
select functable (tablename) into tablenew from dual; --возвращает наличие таблицы
for rec in (select g.acode, g.clcode from general_table g ) loop
if tablename is not null then
execute immediate 'update ' || tablenew || ' set accli = ' || rec.acode || ', clcode= ' || rec.clcode || ''; --данные из таблы general_table обновляются в таблице tablename
end if;
end loop;
end;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question