1

Topic: Variable sheaves

Good evening;
Why PL/SQL transforms variable to variable sheaves for a case:

begin
for i in (select id from t) loop
update t set n = n + 1 where id = i.id;
end loop;
commit;
end;

, And for a case:

begin
for i in (select id from t) loop
execute immediate ' update t set n = n + 1 where id = ' || i.id;
end loop;
commit;
end;

Such conversion does not happen?

2

Re: Variable sheaves

cobalt_frog wrote:

Why

By design, the troll.

3

Re: Variable sheaves

cobalt_frog;
Because in the second case you feed to it a line. Whence to it the nobility that there inside at the moment of parsing of the anonymous unit (in which there is expression EXECUTE IMMEDIATE? - Here also happens dynamic SQL about a hard  at each specific value i.id.
If you want to dynamics with , use force, the Manhole:

execute immediate ' update t set n = n + 1 where id =:id ' using i.id;

though, I do not understand, what for here dynamics