# GENERAR NUMERO

**URL:** <https://foros.velneo.com/t/generar-numero/1458>\
**Category:** Velneo\
**Created:** [15 Enero, 2010 21:54 UTC](https://foros.velneo.com/t/generar-numero/1458 "2010-01-15T21:54:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zamborja](https://avatars.discourse-cdn.com/v4/letter/z/6f9a4e/32.png) [@zamborja](https://foros.velneo.com/u/zamborja)\
**Post date:** [15 Enero, 2010 21:54 UTC](https://foros.velneo.com/t/generar-numero/1458/1 "2010-01-15T21:54:33Z")

</div>

POR FAVOR QUISIERA QUE ME AYUDEN COMO PUEDO HACER UNA NUMERACION QUE EMPIECE NUEVAMENTE A PARTIR DEL NUMERO 1.

YO HE CREADO UN PROGRAMITA EN VELNEO V 6 DONDE CONTROLO LOS CONTRATOS QUE VOY HACIENDO DURANTE EL AÑO (EL CODIGO&nbsp;O EL NUMERO DE CONTRATO SE&nbsp;GENERA AUTOMATICAMENTE).&nbsp;EL AÑO PASADO HE ELABORADO CONTRATOS A PARTIR DEL 1 AL 2480 EN EL AÑO 2009, AHORA EN EL 2010 COMO PUEDO HACER PARA QUE EL PROGRAMA ME GENERE NUEVAMENTE EL NUMERO 1&nbsp;EN ESTE AÑO 2010 &nbsp; Y NO EL CONSECUTIVO QUE ME QUEDE EN EL 2009,,, POR FAVOR ALGUIEN QUIEN ME PUEDA AYUDAR CON ESTO QUISERA SABER COMO SERIA EL ALGORITMO PARA PODER DESARROLLARLO GRACIAS..... CHULUCANAS - PIURA - PERU.

---

<div class="post-metadata">

**Author:** ![mariorafaelvargas](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@mariorafaelvargas](https://foros.velneo.com/u/mariorafaelvargas)\
**Post date:** [15 Enero, 2010 23:23 UTC](https://foros.velneo.com/t/generar-numero/1458/2 "2010-01-15T23:23:51Z")

</div>

Bueno... yo lo hice con un submaestro

Maestro: &nbsp; &nbsp;tabla Año

&nbsp;

Submaestro: &nbsp; Numeracion\_por\_año

&nbsp;

campos:

&nbsp;

año &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maestro de año

&nbsp;

numeracion x año &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Clave codigo con numeracion siguiente.

&nbsp;

En algun lugar del sistema usaba un Proceso Funcion para recoger el numero siguiente en una variable global.

Atentamente

Mario Rafael Vargas

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![innovadb](https://yyz1.discourse-cdn.com/flex035/user_avatar/foros.velneo.com/innovadb/32/5643_2.png) [@innovadb](https://foros.velneo.com/u/innovadb)\
**Post date:** [16 Enero, 2010 13:16 UTC](https://foros.velneo.com/t/generar-numero/1458/3 "2010-01-16T13:16:08Z")

</div>

El sistema de Mario es perfectamente valido si solamente necesitas un contador por ejercicios, pero si necesitas que además sea por empresa, serie o tipo de documeno como en nuestro caso, entonces tienes que crear una tabla de contadores.

&nbsp;

En esa tabla creas un indice de clave unica con los campos que intervienen en los contadores, y en la tabla de CONTRATOS tienes que usar un trigger parecido al que te adjunto en la imagen.

&nbsp;

Un saludo

[attachment=7755,760]

&nbsp;
