declare
   cursor c_actbco is 
   select distinct a.dia,b.banco,b.tipo_movban,a.referencia,a.documento
   from movimientocaja a,concepto b
   where  a.cia = '001'
   and    b.cia = '001'
   and    a.concepto = b.concepto 
   and    a.dia between '01/12/1999' and '31/12/1999'
   and    b.banco is not null
   and    a.documento is not null
   group by a.dia,b.banco,b.tipo_movban,a.referencia,a.documento;

begin
  for reg in c_actbco
  loop
     update banmov
     set num_docref = substr(reg.referencia,1,10)
     where cod_cia  = '001'
     and   cuenta   =  substr(reg.banco,1,20)
     and   tipo_mov = reg.tipo_movban
     and   documento= reg.documento;
  end loop;
end;

