Hallo!
anyone can help me?
Why the following stored procedure, using a FOREACH statement don't loop through all records (500.000), only work with the first record.
How can i to catch an exception?
create procedure vus_SprivSample()
define varCodigoServicio char(20);
define varCircuito char(20);
define varAlready char(1);
foreach sprivCursor for
select serv_nm_servic, circ_nm_cto
into varCodigoServicio, varCircuito
from sprmccto
-- Check if the current record already in the tarjet table
select '1' into varAlready
from vista_unificada
where codigo_servicio = varCodigoServicio
and circuito = varCircuito;
if varAlready is null then
-- Insert the record in the tarjet table
begin work;
insert into vista_unificada (codigo_servicio, circuito)
values (varCodigoServicio, varCircuito);
commit work;
end if
let varOk = '0';
end foreach
end procedure;