Foreach loop in stored procedure

0

Can you have 2 foreach in a stored procedure? example:

I have the following shekel that I only need to do the process once only

FOREACH
insert into tabla 1 (campo1,campo2,campo3)
select campo1_x,campo2_x,campo3_x
from tabla2
where campo1_n=1
END FOREACH

and the second foreach is necessary to do it according to a parameterized amount after a consultation

FOREACH
insert into tabla 3(campo1,campo2,campo3)
select campo1_x,campo2_x,campo3_x
from tabla2=4
where campo1_n=2
END FOREACH

It is possible to do it this way or there is some other way. Currently I only have one foreach, but in the first cycle I'm duplicating the data, in the first table it's just a header, but the second is a detail of several fields, so I only need the first cycle to run only once.

    
asked by Norbey Martinez 16.08.2018 в 00:06
source

0 answers