>
> select mytable
> go bottom
> cod = mytable.cod + 1
> appe blank
> replace mytable.cod with cod
>
>
> I think this rotine is not suitable because some costumers complain
> that for some reason the code become repetead
> Is there a more eficient way to do it ?
this should be a unique-ID, correct. If so, I would employ a second table that holds
the next (or current) Id and counts them up.
I have a table (CONTROL) that has a Key-Field (the Alias or another unique Key) as well as a field for the current Value (your COD).
In my DBC I have a Method NewID() that receives the Alias (i.e. the key) and returns the next ID.
My method is quite complicated and has several options that belong to my applications, but what it merely does is open the CONTROL table (if not), locate the record for the key.
If it cannot find it, initializes it with a starting value otherwise it trys to lock the record (if rlock(....)
sets the value up by one, relieves the lock (unlock) and returns the new value as ID.
Another option would be an Autoincrement-Field if You work with VFP 9