Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Buffering / Record Locking
Message
From
27/08/2002 14:01:59
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Buffering / Record Locking
Miscellaneous
Thread ID:
00694149
Message ID:
00694149
Views:
42
Hi, group, I'm here again.

I'm having some trouble with record locking, and I'm trying to find out what is the right buffering mode I have to use.

There's a table which stores info about the Products reserve and a table which stores the movement for that products.

Whenever there's movement in the reserve, the system launches the movement and the new Reserve for that product in the Movement table, and the new Reserve for the product in the products reserve, all this in a Transaction.

And here comes the trouble: the inserts are normally long, and if one of the stations in the network loses the connection (like the computer is Reset) the recors keep locked, making it impossible for another user to update that record. Here's the code:
lcCod  = [000001] && could be any other code, this is a test code.
lBuff  = CURSORSETPROP("Buffering",2,[g2_estoq])
lBuff2 = CURSORSETPROP("Buffering",2,[g2_estmo])

BEGIN TRANSACTION 
	UPDATE gereswin!g2_estoq SET qtd_est = CalcEstoque(qtd_est,lnValor,@lnSaldo) WHERE codigo=lcCod
	lUp   = TABLEUPDATE(.t.,.t.,[g2_estoq])
 	INSERT INTO g2_estmo (codigo,qtd_lanca,qtd_saldo,historico) VALUES(lcCod,lnValor,lnSaldo,[Pablo])
	lUp2  = TABLEUPDATE(.t.,.t.,[g2_estmo])
	
IF llRollback
        = MESSAGEBOX([Record locked by another user],64,[Warning])
	ROLLBACK
	= TABLEREVERT(.t.,[g2_estoq])
	= TABLEREVERT(.t.,[g2_estmo])
ELSE
	IF lUp AND lUp2
		END TRANSACTION 
	ELSE
		ROLLBACK 
   		= TABLEREVERT(.t.,[g2_estoq])
   		= TABLEREVERT(.t.,[g2_estmo])
	ENDIF
ENDIF 
FLUSH
TIA,
Pablo Márcio de Oliveira

Inside the scream is silent, inside it must remain
Next
Reply
Map
View

Click here to load this message in the networking platform