Dynamic variable names
YogOct 5 2007 — edited Oct 5 2007Hi,
Is there an easy way to dynamically build plsql in the same way as execute immediate works for sql as follows:
declare
v1 number := 10;
v2 number := 20;
v3 number := 30;
v4 number := 40;
v_return number;
begin
for x in 1..4 loop
[something like execute immediate] 'v_return := v'||x;
...do something with v_return....;
end loop;
end;
This is a trivial example but I like to be able to dynamically call variable names like this. It would save a lot of duplication because the only other way I can think of to do it would be repeat the same code for each instance.
Thanks
Yog