>The title says it all!
>
>Is there anybody who have a code snippet for this?
>Everytime a new record is appended to a table one numeric field is to be
>incremented with 1.
>
>Hope there is help on this!
>
>Best regards
>Per Simmersholm
Hi,
this things was often discussed here. You can check older messages for
this. I use this function for that. It's in database's stored procedures,
and as a default value for my field ID in table I have uniq_id(). That means
every time I append record this function is trigerred and returns only valid
unique ID number.
I have table UNIQ_ID, where is only one record and couple fields, that every
field represent one table. And value means next available ID number.
function uniq_id
if !used ('uniq_id')
use main_dbc!uniq_id in 0
endif
sele uniq_id
local llLock
local llRetVal
llLock = .f.
do while !llLock
if rlock()
llLock = .t.
llRetVal = uniq_id.table1_id
replace table1_id with table1_id + 1
unlock
endif
enddo
return llRetVal
hth
Dezider
--
There were three worst disasters in the history of human
race in 20-th century:
1, Hiroshima 44
2, Tchernobyl 86
3, Windows 95