"Dinesh Pandey" <dpandey(at)secf(dot)com> writes:
> FOR _record IN SELECT A1, A2 FROM A
> LOOP
> _sql := 'INSERT INTO B VALUES (:A1, :A2)';
> EXECUTE (_sql);
Why do you need a dynamic query here at all? You could just do
FOR _record IN SELECT A1, A2 FROM A
LOOP
INSERT INTO B VALUES (_record.A1, _record.A2);
This would be much faster as well as simpler to code.
As far as I can see offhand, you only need EXECUTE when you want to
change table and/or field names from one execution to the next of
a particular query. If you have such a problem, you are omitting
the important details ...
regards, tom lane