Lynn,
Here is the code I have been using for years.
You need a table called ref_rences with an integer column called xxx_id.
I have been using this code since before R:base had the autonumber field.
Bill Downall has simelar block of code that after many long discussins it
was decided that is code was better in the nature it works. His code does
not use a table lock and works just as good.
Actually my preferred method anymore is to use the autonumber feature and
use the next function.
Troy Sosamon
*(getref.cmd - Used to get next system identifier)
-- RETURNS VAR vref
set var getref_mes = (cval('MESSAGES'))
SET MES OFF
set var vref int -- PASSED BACK
SET VAR VREF = NULL
set error var er
label get_lock
SET LOCK ref_rences ON
if er <> 0 then
goto get_lock
endif
SELECT xxx_id INTO vref FROM ref_rences WHERE COUNT = 1
SET VAR vref = (.vref + 1)
IF vref is null THEN
-- ERROR - TRY AGAIN
CLS FROM 24 TO 24 RED
WRITE 'ERROR GETTING REF_ID FROM GETREF.CMD - WAITING ' +
AT 24,10 WHITE ON RED
GOTO get_lock
ENDIF
UPDATE ref_rences SET xxx_id = .vref WHERE COUNT = 1
SET LOCK ref_rences OFF
SET MESS .getref_mes
CLE VAR getref_mes
RETURN
===== Original Message from [EMAIL PROTECTED] at 7/10/01 9:36 pm
>Due to some programming constraints, I have to do my own autonumbering field
>management - i.e. not using the standard autonumbered column method. I can
>do this with no problem on a stand-alone application, but I am concerned
>with potential problems if the application is adapted to operate on a
>network in multi-user mode.
>
>I remember a couple of years ago a pretty good discussion on methods for
>doing one's own autonumber routine that avoids duplicate numbers being
>assigned in a multi-user situation. I had this discussion printed out at
>one time, but have lost it. Can some of you give me some refresher
>hints/tips? I have to have this application ready for demonstration in the
>next couple of days, so I will do my stand-alone (single-user) method for
>now, and hopefully modify the code later for conflict-avoidance in
>multi-user mode.
>
>TIA
>Lynn Shelton
>[EMAIL PROTECTED]