Reputation: 141
I have a set of item that has the same name so I add at the end of each the position number like :P77_VARIABLE_1, :P77_VARIABLE_2.
So in the process to add them to my database I must get those item and make a loop. The loop will look like this
for i in 1..:P77_NOMBRE_VARIABLE
loop
l_variable := new SFD_SI_VARIABLE_TYP(sfd_si_variable_seq.nextval, :P77_NOM_VARIABLE_i, :P77_TYPE_VARIABLE_i);
SFD_SI_VARIABLE_PKG.AJOUTER(l_variable);
end loop;
But the problem is this doesn't work. Can someone know a way to execute this loop and adding "dynamically" my item (or a better way for the concatenation with the variable i. Thank you.
Upvotes: 0
Views: 732
Reputation: 60262
Leaving off whether this is a wise thing to do (using individual variables for what should probably be an array, e.g. using an Apex collection), you can use the v()
function for this.
for i in 1..:P77_NOMBRE_VARIABLE
loop
l_variable := new SFD_SI_VARIABLE_TYP(sfd_si_variable_seq.nextval
,v('P77_NOM_VARIABLE_'||i)
,v('P77_TYPE_VARIABLE_'||i));
SFD_SI_VARIABLE_PKG.AJOUTER(l_variable);
end loop;
Upvotes: 3