Is there a way by which we can declare variables in a loop dynamically. I would like to create a vaiables like Var1,Var2,Var3....as and when a new loop begins. If the loop executed 4 times, four such variables has to be created. Kindly help me on this. Thanks.
You must define a host variable between BEGIN DECLARE SECTION and END
if you know the maximum number of loops you might utilize an ARRAY in TD14. I've never done this, but it's possible according to the documentation.
Or you create a Volatile Table within your SP and insert a new row for every loop:
create volatile table vt(n int, variable ...)
unique primary index(n) on commit preserve rows;