Pages

Thursday, April 9, 2020

Execute Immediate






declare
cursor c1 is
select value4,value5,value6,value7 from xxexpd_fnd_lkp_values_t where lkp_def_id = 20601
and value5 is not null
and value1 = 'SCHB';
l_counter number default 0;
l_counter1 number default 0;
l_sql_stmt VARCHAR2(2000);
begin
l_sql_stmt := l_sql_stmt||' begin insert into XXEXPD_KYRIBA_AUTO_RCPT_STG_T (';

for i in c1 loop
if l_counter !=0  then
l_sql_stmt := l_sql_stmt||',';
end if;
l_counter := l_counter+1;
l_sql_stmt := l_sql_stmt || i.value7;
end loop;

l_sql_stmt := l_sql_stmt||') (select ';
for i in c1 loop
if l_counter1!=0 then
l_sql_stmt := l_sql_stmt || ',';
end if;
l_counter1 := l_counter1 +1;

if i.value4 IN ('CONSTANT') THEN
l_sql_stmt := l_sql_stmt || ''''||i.value5||'''';
else
l_sql_stmt := l_sql_stmt || i.value5;
end if;
end loop;
l_sql_stmt := l_sql_stmt||' from OAFLDR$_MT940_T ); end;';
dbms_output.put_line(l_sql_stmt);
execute immediate l_sql_stmt;
end;

No comments:

Post a Comment