Thanks Karen,
I'll do that too. This routine is going to be locked tight! Claudine _____ From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Thursday, August 12, 2010 10:34 AM To: RBASE-L Mailing List Subject: [RBASE-L] - Re: FW: Question to RBASE List Claudine: I see a problem in that you aren't checking whether the 'SET LOCK" fails. It can happen if 2 people are doing it simultaneously (probably small chance of that if your select and update are fast), but also because I've seen tables get locked and never unlocked. You should put your error variable check after the SET LOCK and quit the program if the lock cannot be set. Karen I'm using the following code which regularly burps when more than two users are logged in: ------------------------------------------------------------- --LOCK TABLE TO PREVENT OTHER USERS FROM GRABBING SAME NUMBER ------------------------------------------------------------- SET LOCK d_water_invoice_numbers ON --Grab next invoice number SELECT winvoice_id INTO vwinvoiceid INDICATOR iv1 + FROM d_water_invoice_numbers + WHERE used_nb = 'N' AND LIMIT = 1 --Mark that number as "used" so no one else can attempt to use it! UPDATE d_water_invoice_numbers SET used_nb = 'Y' + WHERE winvoice_id = .vwinvoiceid ------------------------------------------------------------- --UNLOCK TABLE ------------------------------------------------------------- SET LOCK d_water_invoice_numbers OFF ------------------------------------------------------------- Claudine

